diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 449f2a8ad1..b07ab0d3d5 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -160,6 +160,7 @@ void Manager::Process() for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ ) { BasicThread* t = *i; + t->WaitForStop(); all_threads.remove(t); diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index c603f20625..bd16206bb4 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -21,6 +21,8 @@ public: network_time(network_time) { } virtual bool Process() { + if ( Object()->child_finished ) + return true; bool result = Object()->OnFinish(network_time); Object()->Finished(); return result; @@ -90,7 +92,19 @@ public: KillMeMessage(MsgThread* thread) : OutputMessage("ReporterMessage", thread) {} - virtual bool Process() { thread_mgr->KillThread(Object()); return true; } + virtual bool Process() + { + auto rval = true; + + if ( ! Object()->child_finished ) + { + rval = Object()->OnFinish(network_time); + Object()->Finished(); + } + + thread_mgr->KillThread(Object()); + return rval; + } }; #ifdef DEBUG diff --git a/src/threading/MsgThread.h b/src/threading/MsgThread.h index 60da2d9668..1a5834c021 100644 --- a/src/threading/MsgThread.h +++ b/src/threading/MsgThread.h @@ -181,6 +181,7 @@ protected: friend class HeartbeatMessage; friend class FinishMessage; friend class FinishedMessage; + friend class KillMeMessage; /** * Pops a message sent by the child from the child-to-main queue.