From 0605ba282442c02bfaf8a6e4673b50a376e026c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 26 Jan 2020 18:55:40 +0100 Subject: [PATCH] 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. --- src/threading/Queue.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/threading/Queue.h b/src/threading/Queue.h index 4c3453d0c8..ad59f15268 100644 --- a/src/threading/Queue.h +++ b/src/threading/Queue.h @@ -255,7 +255,10 @@ template inline void Queue::WakeUp() { for ( int i = 0; i < NUM_QUEUES; i++ ) + { + auto lock = acquire_lock(mutex[i]); has_data[i].notify_all(); + } } }