task_manger: fix coverity issue 85/317485/2 accepted/tizen/unified/20240911.104743 accepted/tizen/unified/dev/20240913.055444 accepted/tizen/unified/x/20240912.013718
authorInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 02:10:51 +0000 (11:10 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 03:58:47 +0000 (12:58 +0900)
Fix coverity issue - CID 1789482 - Data race condition by making sure locking
before pusing a new thread to _threads.

Change-Id: I94d142822972e057ba7ba9681c1c582589d9a503
Signed-off-by: Inki Dae <inki.dae@samsung.com>
services/task_manager/src/TaskManager.cpp

index 3f5ccd5e65f0f36139bcd00499078149c7ee16ee..df0d8d164c6c05dca470c776f841c1422a997759 100644 (file)
@@ -291,6 +291,9 @@ void TaskManager::run()
 
                        // TODO. consider for multiple sources later.
                        n->setInputBuffer(inputBuffer);
+
+                       std::lock_guard<std::mutex> lock(_thread_mutex);
+
                        _threads.push(make_shared<thread>(&TaskManager::threadCb, this, std::ref(n)));
                        _is_thread_created.insert(n);
                }