From: Changgyu Choi Date: Tue, 26 Dec 2023 07:04:17 +0000 (+0900) Subject: Fix deadlock issue X-Git-Tag: accepted/tizen/8.0/unified/20231227.170213~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b695ca3e229a563b9ed95b10ffdd3a454ea2bc6;p=platform%2Fcore%2Fappfw%2Frpc-port.git Fix deadlock issue This patch fixes deadlock issue. When CynaraThread was blocked from WaitAndPop() and the instance was desctucted at the same time, CynaraThread occurs deadlock. Change-Id: Iee2c6fb02dd1f5fd6b9b5331c4d87ddbbb880697 Signed-off-by: Changgyu Choi --- diff --git a/src/cynara_thread.cc b/src/cynara_thread.cc index 17b7ee3..a5a2f67 100644 --- a/src/cynara_thread.cc +++ b/src/cynara_thread.cc @@ -41,7 +41,7 @@ CynaraThread::CynaraThread() { // LCOV_EXCL_START CynaraThread::~CynaraThread() { - finished_ = true; + queue_.Push(Job()); thread_.join(); } // LCOV_EXCL_STOP @@ -49,10 +49,8 @@ CynaraThread::~CynaraThread() { void CynaraThread::ThreadRun() { while (true) { Job job = queue_.WaitAndPop(); - if (finished_) + if (job.Do() == Job::Type::Finish) return; // LCOV_EXCL_LINE - - job.Do(); } } diff --git a/src/cynara_thread.hh b/src/cynara_thread.hh index 04d76cd..3babdd3 100644 --- a/src/cynara_thread.hh +++ b/src/cynara_thread.hh @@ -17,7 +17,6 @@ #ifndef CYNARA_THREAD_HH_ #define CYNARA_THREAD_HH_ -#include #include #include #include @@ -59,7 +58,6 @@ class CynaraThread { Job Pop(); std::thread thread_; - std::atomic finished_ = false; mutable tizen_base::SharedQueue queue_; };