mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
BIT-1885: fix input framework memory leak
For input threads that get joined during run-time instead of being signalled to stop at termination-time as typical (e.g. an error occurs or process exits w/ non-zero status) messages could remain in the thread's queue and leak. This patches threads to ensure they enter the proper "finished" state so that the thread manager can attempt to fully process and empty out their queues before joining them.
This commit is contained in:
parent
f5848f0279
commit
b847b3b4d9
3 changed files with 17 additions and 1 deletions
|
@ -160,6 +160,7 @@ void Manager::Process()
|
||||||
for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ )
|
for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ )
|
||||||
{
|
{
|
||||||
BasicThread* t = *i;
|
BasicThread* t = *i;
|
||||||
|
t->WaitForStop();
|
||||||
|
|
||||||
all_threads.remove(t);
|
all_threads.remove(t);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
network_time(network_time) { }
|
network_time(network_time) { }
|
||||||
|
|
||||||
virtual bool Process() {
|
virtual bool Process() {
|
||||||
|
if ( Object()->child_finished )
|
||||||
|
return true;
|
||||||
bool result = Object()->OnFinish(network_time);
|
bool result = Object()->OnFinish(network_time);
|
||||||
Object()->Finished();
|
Object()->Finished();
|
||||||
return result;
|
return result;
|
||||||
|
@ -90,7 +92,19 @@ public:
|
||||||
KillMeMessage(MsgThread* thread)
|
KillMeMessage(MsgThread* thread)
|
||||||
: OutputMessage<MsgThread>("ReporterMessage", thread) {}
|
: OutputMessage<MsgThread>("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
|
#ifdef DEBUG
|
||||||
|
|
|
@ -181,6 +181,7 @@ protected:
|
||||||
friend class HeartbeatMessage;
|
friend class HeartbeatMessage;
|
||||||
friend class FinishMessage;
|
friend class FinishMessage;
|
||||||
friend class FinishedMessage;
|
friend class FinishedMessage;
|
||||||
|
friend class KillMeMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops a message sent by the child from the child-to-main queue.
|
* Pops a message sent by the child from the child-to-main queue.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue