Prevent duplicate "finish" threading messages

As they don't get processed and may show up as a memory leak.
This commit is contained in:
Jon Siwek 2019-12-27 07:35:59 -08:00
parent 3742e5601c
commit 9e07b8a9f1
2 changed files with 4 additions and 1 deletions

View file

@ -176,6 +176,7 @@ MsgThread::MsgThread() : BasicThread(), queue_in(this, 0), queue_out(0, this)
cnt_sent_in = cnt_sent_out = 0; cnt_sent_in = cnt_sent_out = 0;
main_finished = false; main_finished = false;
child_finished = false; child_finished = false;
child_sent_finish = false;
failed = false; failed = false;
thread_mgr->AddMsgThread(this); thread_mgr->AddMsgThread(this);
} }
@ -185,9 +186,10 @@ extern int signal_val;
void MsgThread::OnSignalStop() void MsgThread::OnSignalStop()
{ {
if ( main_finished || Killed() ) if ( main_finished || Killed() || child_sent_finish )
return; return;
child_sent_finish = true;
// Signal thread to terminate. // Signal thread to terminate.
SendIn(new FinishMessage(this, network_time), true); SendIn(new FinishMessage(this, network_time), true);
} }

View file

@ -306,6 +306,7 @@ private:
bool main_finished; // Main thread is finished, meaning child_finished propagated back through message queue. bool main_finished; // Main thread is finished, meaning child_finished propagated back through message queue.
bool child_finished; // Child thread is finished. bool child_finished; // Child thread is finished.
bool child_sent_finish; // Child thread asked to be finished.
bool failed; // Set to true when a command failed. bool failed; // Set to true when a command failed.
}; };