Avoid adding elements to QueueingThread if it's stopped. (#596) 42/217942/1
authorsenthil.gs@samsung.com <senthil.gs@samsung.com>
Wed, 6 Nov 2019 09:56:00 +0000 (15:26 +0530)
committerSudipto Bal <sudipto.bal@samsung.com>
Mon, 18 Nov 2019 02:22:27 +0000 (11:22 +0900)
commitbf7c1453bb2758293c8f544fee1c9897438be5d3
treec639b63e3cbcd885a7f9a5f620806148cc9d17d8
parent539a046a8d6b8ed794a8f713372f31410b38268d
Avoid adding elements to QueueingThread if it's stopped. (#596)

* Avoid adding elements to QueueingThread if it's stopped.

Background:-
-> 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 which might
result in race condition/unwanted behavior.

This will have a positive impact for CONPRO-1515 in which IP send thread was not stopped during OCStop() and new requests were getting added.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/596/commits/a9cc86c208e1cf19d2725681d9e45dcb9ec8f663
(cherry-picked from a9cc86c208e1cf19d2725681d9e45dcb9ec8f663)

Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
* Indentation fix.

Change-Id: Iad6b385b0bf77bc1a9fabc1525a9acbcecc5bef3
Signed-off-by: Sudipto Bal <sudipto.bal@samsung.com>
resource/csdk/connectivity/inc/caqueueingthread.h
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caqueueingthread.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/nfc_adapter/canfcadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c