From c137dfa21360af28edc35128d2637ce543524a4b Mon Sep 17 00:00:00 2001 From: Stanislav Angelovic Date: Tue, 16 Jun 2020 17:43:29 +0200 Subject: [PATCH] Fix potential data race in Proxy's condition variable --- src/Proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Proxy.cpp b/src/Proxy.cpp index 644a972..25665f8 100644 --- a/src/Proxy.cpp +++ b/src/Proxy.cpp @@ -127,8 +127,8 @@ MethodReply Proxy::sendMethodCallMessageAndWaitForReply(const MethodCall& messag void Proxy::SyncCallReplyData::sendMethodReplyToWaitingThread(MethodReply& reply, const Error* error) { - SCOPE_EXIT{ cond_.notify_one(); }; std::unique_lock lock{mutex_}; + SCOPE_EXIT{ cond_.notify_one(); }; // This must happen before unlocking the mutex to avoid potential data race on spurious wakeup in the waiting thread SCOPE_EXIT{ arrived_ = true; }; //error_ = nullptr; // Necessary if SyncCallReplyData instance is thread_local