fix to pending terminate logic when call OCStop.
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 11 Jan 2017 08:01:05 +0000 (17:01 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 16 Jan 2017 09:29:13 +0000 (09:29 +0000)
Change-Id: If5e02f49b8d0a69c6b2d1ed90ba9370f9da6328e
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16313
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.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
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c

index 0b299a3..62cd60a 100644 (file)
@@ -809,6 +809,7 @@ CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address)
                                  g_threadSendMutex,
                                  TIMEOUT) == OC_WAIT_SUCCESS)
             {
+                OIC_LOG(DEBUG, TAG, "time out");
                 oc_mutex_lock(g_deviceListMutex);
                 size_t scannedDeviceLen = u_arraylist_length(g_deviceList);
                 oc_mutex_unlock(g_deviceListMutex);
@@ -4235,6 +4236,11 @@ void CAStopLEGattClient()
     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);
index d29d474..a42c55f 100644 (file)
@@ -2618,15 +2618,21 @@ static CAResult_t CALEAdapterGattServerStop()
 #ifndef SINGLE_THREAD
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattServerStop");
 
-    CAResult_t result = CAStopLEGattServer();
+    CAResult_t res = CAStopLEGattServer();
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG(ERROR, CALEADAPTER_TAG, "CAStopLEGattServer has failed");
+    }
+
     oc_mutex_lock(g_bleServerSendDataMutex);
-    if (CA_STATUS_OK == result)
+    res = CAQueueingThreadStop(g_bleServerSendQueueHandle);
+    if (CA_STATUS_OK != res)
     {
-        result = CAQueueingThreadStop(g_bleServerSendQueueHandle);
+        OIC_LOG(ERROR, CALEADAPTER_TAG, "CAQueueingThreadStop has failed");
     }
     oc_mutex_unlock(g_bleServerSendDataMutex);
 
-    return result;
+    return res;
 #else
     return CAStopLEGattServer();
 #endif
@@ -2880,7 +2886,7 @@ static CAResult_t CAStopLE()
 
 static void CATerminateLE()
 {
-    OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CATerminateLE");
 
     CASetLEReqRespServerCallback(NULL);
     CASetLEReqRespClientCallback(NULL);
@@ -2917,7 +2923,7 @@ static void CATerminateLE()
 
     CATerminateLEAdapterMutex();
 
-    OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT - CATerminateLE");
 }
 
 static CAResult_t CAStartLEListeningServer()