Remove presumed ownership of HeartbeatTimer

threading::Manager is currently never deleted, but if that ever changes,
deleting the stored HeartbeatTimer pointer would be a double-free
since TimerMgr owns it.
This commit is contained in:
Jon Siwek 2020-02-05 17:50:56 -08:00
parent e62c0e0c9f
commit 7f76381f13
4 changed files with 21 additions and 8 deletions

View file

@ -30,9 +30,6 @@ Manager::~Manager()
{
if ( all_threads.size() )
Terminate();
if ( heartbeat_timer )
delete heartbeat_timer;
}
void Manager::Terminate()
@ -68,7 +65,7 @@ void Manager::AddThread(BasicThread* thread)
DBG_LOG(DBG_THREADING, "Adding thread %s ...", thread->Name());
all_threads.push_back(thread);
if ( ! heartbeat_timer )
if ( ! heartbeat_timer_running )
StartHeartbeatTimer();
}
@ -127,8 +124,8 @@ void Manager::SendHeartbeats()
void Manager::StartHeartbeatTimer()
{
heartbeat_timer = new HeartbeatTimer(network_time + BifConst::Threading::heartbeat_interval);
timer_mgr->Add(heartbeat_timer);
heartbeat_timer_running = true;
timer_mgr->Add(new HeartbeatTimer(network_time + BifConst::Threading::heartbeat_interval));
}
void Manager::Flush()