Fix potential data race in Proxy's condition variable

This commit is contained in:
Stanislav Angelovic authored and Stanislav Angelovič committed 2020-06-17 09:13:30 +02:00
1 parent a0dadcc6fe
commit c137dfa213
1 file changed
+1 -1
+1 -1
View File
@@ -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