From 22d35d2c8cb8da0ee897503e2f82f8efeccc84ae Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 29 Oct 2013 14:40:07 -0500 Subject: [PATCH] Fix thread processing/termination conditions. A thread that is done/killed should signify that the thread manager has some processing to do -- it needs to process any messages in its out queue, join the thread, and delete it. Otherwise the thread manager may reach a state where it makes no progress in processing the last remaining done/killed thread. --- src/threading/Manager.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 1b6cb551e2..4491cd42b5 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -82,7 +82,10 @@ double Manager::NextTimestamp(double* network_time) { MsgThread* t = *i; - if ( (*i)->MightHaveOut() && ! t->Killed() ) + if ( t->MightHaveOut() || t->Killed() ) + // Even if the thread doesn't have output, it may be killed/done, + // which should also signify that processing is needed. The + // "processing" in that case is joining the thread and deleting it. return timer_mgr->Time(); } @@ -149,10 +152,8 @@ void Manager::Process() { BasicThread* t = *i; - if ( ! t->Killed() ) - continue; - - to_delete.push_back(t); + if ( t->Killed() ) + to_delete.push_back(t); } for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ )