mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
threading/MsgThread: Decouple IO source and thread lifetimes
MsgThread acting as an IO source can result in the situation where the threading manager's heartbeat timer deletes a finished MsgThread instance, but at the same time this thread is in the list of ready IO sources the main loop is currently processing. Fix this by decoupling the lifetime of the IO source part and properly registering as lifetime managed IO sources with the IO manager. Fixes #3682
This commit is contained in:
parent
0451a4038c
commit
b3118d2a48
2 changed files with 68 additions and 16 deletions
|
@ -26,6 +26,7 @@ class HeartbeatMessage;
|
|||
class FinishMessage;
|
||||
class FinishedMessage;
|
||||
class KillMeMessage;
|
||||
class IOSource;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
@ -40,7 +41,7 @@ class KillMeMessage;
|
|||
* that happens, the thread stops accepting any new messages, finishes
|
||||
* processes all remaining ones still in the queue, and then exits.
|
||||
*/
|
||||
class MsgThread : public BasicThread, public iosource::IOSource {
|
||||
class MsgThread : public BasicThread {
|
||||
public:
|
||||
/**
|
||||
* Constructor. It automatically registers the thread with the
|
||||
|
@ -209,11 +210,9 @@ public:
|
|||
void GetStats(Stats* stats);
|
||||
|
||||
/**
|
||||
* Overridden from iosource::IOSource.
|
||||
* Process() forwarded to from detail::IOSource.
|
||||
*/
|
||||
void Process() override;
|
||||
const char* Tag() override { return Name(); }
|
||||
double GetNextTimeout() override { return -1; }
|
||||
void Process();
|
||||
|
||||
protected:
|
||||
friend class Manager;
|
||||
|
@ -362,7 +361,7 @@ private:
|
|||
bool child_sent_finish; // Child thread asked to be finished.
|
||||
bool failed; // Set to true when a command failed.
|
||||
|
||||
zeek::detail::Flare flare;
|
||||
detail::IOSource* io_source = nullptr; // IO source registered with the IO manager.
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue