patched BroadcastDiscivery and GxsNetTunnel so that they respond faster to shutdown

This commit is contained in:
csoler 2021-01-19 20:44:21 +01:00
parent 5fc3108533
commit 0757b161ba
3 changed files with 14 additions and 5 deletions

View File

@ -766,7 +766,12 @@ void RsGxsNetTunnelService::threadTick()
}
#endif
rstime::rs_usleep(1*1000*1000) ; // 1 sec
for(uint32_t i=0;i<2;++i)
{
if(shouldStop())
return;
rstime::rs_usleep(500*1000) ; // 1 sec
}
}
const Bias20Bytes& RsGxsNetTunnelService::locked_randomBias()

View File

@ -141,8 +141,6 @@ void BroadcastDiscoveryService::updatePublishedData()
void BroadcastDiscoveryService::threadTick()
{
auto nextRunAt = std::chrono::system_clock::now() + std::chrono::seconds(5);
if( mUdcParameters.can_discover() &&
!mRsPeers.isHiddenNode(mRsPeers.getOwnId()) )
{
@ -200,7 +198,13 @@ void BroadcastDiscoveryService::threadTick()
if( mUdcParameters.can_be_discovered() &&
!mRsPeers.isHiddenNode(mRsPeers.getOwnId()) ) updatePublishedData();
std::this_thread::sleep_until(nextRunAt);
// This avoids waiting 5 secs when the thread should actually terminate (when RS closes).
for(uint32_t i=0;i<10;++i)
{
if(shouldStop())
return;
rstime::rs_usleep(500*1000); // sleep for 0.5 sec.
}
}
RsBroadcastDiscoveryResult BroadcastDiscoveryService::createResult(

View File

@ -377,7 +377,7 @@ MainWindow::~MainWindow()
delete sysTrayStatus;
delete trayIcon;
delete trayMenu;
// delete notifyMenu;
// delete notifyMenu; // already deleted by the deletion of trayMenu
#ifdef MESSENGER_WINDOW
MessengerWindow::releaseInstance();
#endif