Backgraund:-
-> If a thread has called CAQueueingThreadStop(), it signals the condition variable
to wake up the CAQueueingThreadBaseRoutine.
-> After signaling, it waits on the same condition variable
to wait for the completion of CAQueueingThreadBaseRoutine.
-> CAQueueingThreadBaseRoutine will finish its current task and signals the condition variable.
-> CAQueueingThreadStop should wake up upon signal and return back to caller.
Issue:-
-> CAQueueingThreadAddData also signals the condition variable which can wake up the thread that called CAQueueingThreadStop.
-> CAQueueingThreadStop returns back to caller assuming that the CAQueueingThreadBaseRoutine has stopped. But it could still be running.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/475
(cherry picked from
069d45ab60a7cd90d451aea4fdcf9d03dda421de)
Change-Id: Ib64d83a2560f31d44cb33148eba4f8b4e9a1289e
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
// mutex lock
oc_mutex_lock(thread->threadMutex);
+ // thread stop
+ if (thread->isStop)
+ {
+ // mutex unlock
+ oc_mutex_unlock(thread->threadMutex);
+
+ OICFree(message);
+ return CA_STATUS_FAILED;
+ }
+
// add thread data into list
u_queue_add_element(thread->dataQueue, message);