Add a missing mutex lock 20/320020/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 6 Nov 2024 11:08:45 +0000 (20:08 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 7 Nov 2024 00:00:51 +0000 (00:00 +0000)
Before using condition variable, we should lock the mutex to avoid
a timing issue.

Change-Id: I78c22d275a3dfc08087ec722cb9d0c53d08c3c19
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
(cherry picked from commit 6433da6a2005ab739e9672ea0ec1532b37f95ff9)

src/rpc-port/cynara_thread.cc

index 01458402ebd4096874265d4248063c4dca88f486..fbb2ee8faab7b0219b6c2cf56d1d459dedeea9c1 100644 (file)
@@ -49,8 +49,11 @@ CynaraThread::~CynaraThread() {
 void CynaraThread::Dispose() {
   if (disposed_) return;
 
-  done_ = true;
-  cond_var_.notify_one();
+  {
+    std::lock_guard<std::mutex> lock(mutex_);
+    done_ = true;
+    cond_var_.notify_one();
+  }
   thread_.join();
   disposed_ = true;
 }