Update snapshot(2018-01-31)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / tcp_adapter / catcpadapter.c
index 165e3db..cd33343 100644 (file)
@@ -444,6 +444,8 @@ CAResult_t CAStartTCP()
 
 static bool CAClearQueueEndpointDataContext(void *data, uint32_t size, void *ctx)
 {
+    (void)size;
+
     if (NULL == data || NULL == ctx)
     {
         return false;
@@ -465,21 +467,19 @@ static bool CAClearQueueEndpointDataContext(void *data, uint32_t size, void *ctx
 
 CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint)
 {
-    CAResult_t res = CA_STATUS_OK;
+    CAResult_t res = CAQueueingThreadClearContextData(g_sendQueueHandle,
+                                                      CAClearQueueEndpointDataContext,
+                                                      endpoint);
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG(ERROR, TAG, "failed to clear context data");
+    }
+
 #ifdef __WITH_TLS__
     res = CAcloseSslConnection(endpoint);
     if (CA_STATUS_OK != res)
     {
         OIC_LOG(ERROR, TAG, "failed to close TLS session");
-        res = CAQueueingThreadClearContextData(g_sendQueueHandle,
-                                               CAClearQueueEndpointDataContext,
-                                               endpoint);
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, TAG, "failed to clear context data");
-        }
-
-        return res;
     }
 #endif
 
@@ -489,14 +489,6 @@ CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint)
         OIC_LOG(ERROR, TAG, "failed to close TCP session");
     }
 
-    res = CAQueueingThreadClearContextData(g_sendQueueHandle,
-                                           CAClearQueueEndpointDataContext,
-                                           endpoint);
-    if (CA_STATUS_OK != res)
-    {
-        OIC_LOG(ERROR, TAG, "failed to clear context data");
-    }
-
     return res;
 }