Fix blocking issue when OCStop is called in android BLE. 77/17077/3
authorjihwan.seo <jihwan.seo@samsung.com>
Mon, 6 Feb 2017 09:38:42 +0000 (18:38 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 13 Feb 2017 06:51:00 +0000 (06:51 +0000)
Change-Id: If115ae64a1b85fa30a1af184698552b28925084b
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17077
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c

index 1c63fb4..c1631a7 100644 (file)
@@ -3925,22 +3925,17 @@ void CAStopLEGattClient()
 
     CALEClientStopScanWithInterval();
 
-    oc_mutex_lock(g_threadMutex);
-    OIC_LOG(DEBUG, TAG, "signal - connection cond");
-    oc_cond_signal(g_threadCond);
-    CALEClientSetSendFinishFlag(true);
-    oc_mutex_unlock(g_threadMutex);
-
-    oc_mutex_lock(g_threadSendMutex);
-    OIC_LOG(DEBUG, TAG, "signal - g_deviceDesc cond");
-    oc_cond_signal(g_deviceDescCond);
-    oc_mutex_unlock(g_threadSendMutex);
-
     oc_mutex_lock(g_threadWriteCharacteristicMutex);
     OIC_LOG(DEBUG, TAG, "signal - WriteCharacteristic cond");
     oc_cond_signal(g_threadWriteCharacteristicCond);
     oc_mutex_unlock(g_threadWriteCharacteristicMutex);
 
+    CALEClientSetSendFinishFlag(true);
+    oc_mutex_lock(g_threadMutex);
+    OIC_LOG(DEBUG, TAG, "signal - g_threadCond cond");
+    oc_cond_signal(g_threadCond);
+    oc_mutex_unlock(g_threadMutex);
+
     oc_mutex_lock(g_deviceScanRetryDelayMutex);
     OIC_LOG(DEBUG, TAG, "signal - delay cond");
     oc_cond_signal(g_deviceScanRetryDelayCond);
@@ -3951,6 +3946,11 @@ void CAStopLEGattClient()
     oc_cond_signal(g_threadScanIntervalCond);
     oc_mutex_unlock(g_threadScanIntervalMutex);
 
+    oc_mutex_lock(g_threadSendMutex);
+    OIC_LOG(DEBUG, TAG, "signal - g_deviceDesc cond");
+    oc_cond_signal(g_deviceDescCond);
+    oc_mutex_unlock(g_threadSendMutex);
+
     oc_cond_free(g_deviceDescCond);
     oc_cond_free(g_threadCond);
     oc_cond_free(g_threadWriteCharacteristicCond);
@@ -3979,9 +3979,10 @@ CAResult_t CAInitializeLEGattClient()
 
 void CATerminateLEGattClient()
 {
-    OIC_LOG(DEBUG, TAG, "Terminate GATT Client");
+    OIC_LOG(INFO, TAG, "IN - Terminate GATT Client");
     CAStopLEGattClient();
     CALEClientTerminate();
+    OIC_LOG(INFO, TAG, "OUT - Terminate GATT Client");
 }
 
 CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t  *data,