static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle,
ca_mutex mutex,
const char* address);
+
+/**
+ * remove all received data of data list from receive queue.
+ *
+ * @param[in] dataInfoList received data list to remove for client / server.
+ * @param[in] address target address to remove data in queue.
+ */
+static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList,
+ const char* address);
#endif
static CAResult_t CAInitLEServerQueues()
static CAResult_t CALEAdapterGattServerStop()
{
#ifndef SINGLE_THREAD
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattServerStop");
+
+ CAResult_t result = CAStopLEGattServer();
ca_mutex_lock(g_bleServerSendDataMutex);
- CAResult_t result = CAQueueingThreadStop(g_bleServerSendQueueHandle);
- ca_mutex_unlock(g_bleServerSendDataMutex);
- if (CA_STATUS_OK == result)
+ if (CA_STATUS_OK != result)
{
- result = CAStopLEGattServer();
+ result = CAQueueingThreadStop(g_bleServerSendQueueHandle);
}
+ ca_mutex_unlock(g_bleServerSendDataMutex);
return result;
#else
static CAResult_t CALEAdapterGattClientStop()
{
#ifndef SINGLE_THREAD
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattClientStop");
+ CAStopLEGattClient();
+
ca_mutex_lock(g_bleClientSendDataMutex);
CAResult_t result = CAQueueingThreadStop(g_bleClientSendQueueHandle);
ca_mutex_unlock(g_bleClientSendDataMutex);
- if (CA_STATUS_OK == result)
- {
- CAStopLEGattClient();
- }
return result;
#else
#ifndef SINGLE_THREAD
if(g_bleClientSenderInfo)
{
- CABLESenderInfo_t *senderInfo = NULL;
- uint32_t senderIndex = 0;
-
- if(CA_STATUS_OK == CALEGetSenderInfo(address, g_bleClientSenderInfo, &senderInfo,
- &senderIndex))
- {
- u_arraylist_remove(g_bleClientSenderInfo, senderIndex);
- OICFree(senderInfo->defragData);
- OICFree(senderInfo->remoteEndpoint);
- OICFree(senderInfo);
+ CALERemoveReceiveQueueData(g_bleClientSenderInfo, address);
+ }
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo is removed for disconnection");
- }
- else
- {
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo doesn't exist");
- }
+ if(g_bleServerSenderInfo)
+ {
+ CALERemoveReceiveQueueData(g_bleServerSenderInfo, address);
}
// remove data of send queue.
}
ca_mutex_unlock(mutex);
}
+
+static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* address)
+{
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveSendQueueData");
+
+ VERIFY_NON_NULL_VOID(dataInfoList, CALEADAPTER_TAG, "dataInfoList");
+ VERIFY_NON_NULL_VOID(address, CALEADAPTER_TAG, "address");
+
+ CABLESenderInfo_t *senderInfo = NULL;
+ uint32_t senderIndex = 0;
+
+ if(CA_STATUS_OK == CALEGetSenderInfo(address, dataInfoList, &senderInfo,
+ &senderIndex))
+ {
+ u_arraylist_remove(dataInfoList, senderIndex);
+ OICFree(senderInfo->defragData);
+ OICFree(senderInfo->remoteEndpoint);
+ OICFree(senderInfo);
+
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo is removed for disconnection");
+ }
+ else
+ {
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo doesn't exist");
+ }
+}
#endif