mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
cluster/OnLoop: Fix coverity report about proc accessed without lock
Coverity complains proc is set under a lock, but accessed in Process() without a lock. Fix this by setting it in Close() also without locking. The proc member should only ever be accessed my the main thread.
This commit is contained in:
parent
b9b268bd86
commit
4101efed4f
1 changed files with 8 additions and 3 deletions
|
@ -81,8 +81,16 @@ public:
|
|||
* Close the IO source.
|
||||
*/
|
||||
void Close() {
|
||||
if ( std::this_thread::get_id() != main_thread_id ) {
|
||||
fprintf(stderr, "OnLoopProcess::Close() not called by main thread!");
|
||||
abort();
|
||||
}
|
||||
|
||||
zeek::iosource_mgr->UnregisterFd(flare.FD(), this);
|
||||
|
||||
// Ensure Process() is short-circuited from now on.
|
||||
proc = nullptr;
|
||||
|
||||
{
|
||||
// Close under lock to guarantee visibility for
|
||||
// any pending queuers QueueForProcessing() calls.
|
||||
|
@ -91,9 +99,6 @@ public:
|
|||
|
||||
// Wake a process stuck in queueing.
|
||||
cond.notify_one();
|
||||
|
||||
// Don't attempt to Process anymore.
|
||||
proc = nullptr;
|
||||
}
|
||||
|
||||
// Wait for any active queuers to vanish, should be quick.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue