From 26c915b338de27919fca6352678232cd3cebaec6 Mon Sep 17 00:00:00 2001 From: "jihwan.seo" Date: Wed, 11 Jan 2017 17:01:05 +0900 Subject: [PATCH] fix to pending terminate logic when call OCStop. Change-Id: If5e02f49b8d0a69c6b2d1ed90ba9370f9da6328e Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/16313 Tested-by: jenkins-iotivity Reviewed-by: Jaehong Jo Reviewed-by: Dan Mihai Reviewed-by: Ashok Babu Channa --- .../src/bt_le_adapter/android/caleclient.c | 6 ++++++ .../csdk/connectivity/src/bt_le_adapter/caleadapter.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c index 0b299a3..62cd60a 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c @@ -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); diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index d29d474..a42c55f 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -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() -- 2.7.4