Update snapshot(2018-02-07)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / tcp_adapter / catcpadapter.c
index 8056418..9eb0c76 100644 (file)
@@ -374,6 +374,21 @@ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
         return res;
     }
 
+    res = CATCPCreateSendMutex();
+    if (CA_STATUS_OK == res)
+    {
+        res = CATCPCreateSendCond();
+    }
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG(ERROR, TAG, "failed to create send data mutex/cond");
+        CATCPDestroyMutex();
+        CATCPDestroyCond();
+        CATCPDestroySendMutex();
+        CATCPDestroySendCond();
+        return res;
+    }
+
 #ifndef SINGLE_THREAD
     caglobals.tcp.threadpool = handle;
 #endif
@@ -480,7 +495,6 @@ CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint)
     if (CA_STATUS_OK != res)
     {
         OIC_LOG(ERROR, TAG, "failed to close TLS session");
-        return res;
     }
 #endif
 
@@ -626,6 +640,9 @@ void CATerminateTCP()
 
     CATCPDestroyMutex();
     CATCPDestroyCond();
+
+    CATCPDestroySendMutex();
+    CATCPDestroySendCond();
 }
 
 void CATCPSendDataThread(void *threadData)