[IOT-1576] Changed error handling logic when tls message send failed
authorMinji Park <minjii.park@samsung.com>
Fri, 18 Nov 2016 02:48:12 +0000 (11:48 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 5 Dec 2016 07:16:38 +0000 (07:16 +0000)
- Changed error handling logic when tls message send failed
  in tcpadapter.

Change-Id: I22d11d34d2092a7f452d41be9f243dcfdf16a02d
Signed-off-by: Hyuna Jo <hyuna0213.jo@samsung.com>
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14493
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
(cherry picked from commit 5f39be87c9c3a9c657c9828260a9db5e383cee6c)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14771

resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c

index aa5a7d3..f5d8f53 100644 (file)
@@ -225,11 +225,6 @@ static ssize_t CATCPPacketSendCB(CAEndpoint_t *endpoint, const void *data, size_
     OIC_LOG_BUFFER(DEBUG, TAG, data, dataLength);
 
     ssize_t ret = CATCPSendData(endpoint, data, dataLength);
-    if (-1 == ret)
-    {
-        CASearchAndDeleteTCPSession(endpoint);
-        CATCPErrorHandler(endpoint, data, dataLength, CA_SEND_FAILED);
-    }
     OIC_LOG_V(DEBUG, TAG, "Out %s : %d bytes sent", __func__, ret);
     return ret;
 }
@@ -592,6 +587,9 @@ void CATCPSendDataThread(void *threadData)
              if (CA_STATUS_OK != result)
              {
                  OIC_LOG(ERROR, TAG, "CAAdapterNetDtlsEncrypt failed!");
+                 CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
+                 CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
+                                   CA_SEND_FAILED);
              }
              OIC_LOG_V(DEBUG, TAG,
                        "CAAdapterNetDtlsEncrypt returned with result[%d]", result);
@@ -602,6 +600,7 @@ void CATCPSendDataThread(void *threadData)
          ssize_t dlen = CATCPSendData(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen);
          if (-1 == dlen)
          {
+             OIC_LOG(ERROR, TAG, "CATCPSendData failed");
              CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
              CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
                                CA_SEND_FAILED);