mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
threading/Queue: lock mutex before notifying the condition_variable
Locking the associated mutex is not strictly mandatory, but not doing so can easily create race conditions and lockups.
This commit is contained in:
parent
2a7f2e0217
commit
0605ba2824
1 changed files with 3 additions and 0 deletions
|
@ -255,7 +255,10 @@ template<typename T>
|
|||
inline void Queue<T>::WakeUp()
|
||||
{
|
||||
for ( int i = 0; i < NUM_QUEUES; i++ )
|
||||
{
|
||||
auto lock = acquire_lock(mutex[i]);
|
||||
has_data[i].notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue