put NULL check and corrected the debug log in CASendThreadProcess
authorsonu1.yadav <sonu1.yadav@samsung.com>
Tue, 14 Jul 2015 05:16:22 +0000 (10:46 +0530)
committerErich Keane <erich.keane@intel.com>
Thu, 16 Jul 2015 01:36:35 +0000 (01:36 +0000)
Change-Id: I49d3dd4afb71724e6a17cbfb43e777a1efae20e9
Signed-off-by: sonu1.yadav <sonu1.yadav@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1643
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/camessagehandler_singlethread.c

index a4e37c3..2a5d507 100644 (file)
@@ -251,6 +251,7 @@ static void CASendThreadProcess(void *threadData)
     if (SEND_TYPE_UNICAST == type)
     {
 
+        OIC_LOG(DEBUG,TAG,"Unicast message");
         if (NULL != data->requestInfo)
         {
             OIC_LOG(DEBUG, TAG, "requestInfo is available..");
@@ -266,6 +267,7 @@ static void CASendThreadProcess(void *threadData)
         else
         {
             OIC_LOG(DEBUG, TAG, "request info, response info is empty");
+            return;
         }
 
         // interface controller function call.
@@ -292,30 +294,46 @@ static void CASendThreadProcess(void *threadData)
 
             coap_delete_pdu(pdu);
         }
+        else
+        {
+            OIC_LOG_V(ERROR,TAG,"Failed to generate unicast PDU");
+            return;
+        }
     }
     else if (SEND_TYPE_MULTICAST == type)
     {
-        OIC_LOG(DEBUG, TAG, "both requestInfo & responseInfo is not available");
+        OIC_LOG(DEBUG,TAG,"Multicast message");
+        if (NULL != data->requestInfo)
+        {
+            OIC_LOG(DEBUG, TAG, "requestInfo is available..");
+            CAInfo_t *info = &data->requestInfo->info;
 
-        CAInfo_t *info = &data->requestInfo->info;
+            info->options = data->options;
+            info->numOptions = data->numOptions;
 
-        info->options = data->options;
-        info->numOptions = data->numOptions;
+            pdu = CAGeneratePDU(CA_GET, info);
+            if (NULL != pdu)
+            {
+                CALogPDUInfo(pdu);
 
-        pdu = CAGeneratePDU(CA_GET, info);
-        if (NULL != pdu)
-        {
-            CALogPDUInfo(pdu);
+                res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+                if (CA_STATUS_OK != res)
+                {
+                    OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+                    coap_delete_pdu(pdu);
+                    return;
+                }
 
-            res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
-            if (CA_STATUS_OK != res)
-            {
-                OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
                 coap_delete_pdu(pdu);
-                return;
             }
-
-            coap_delete_pdu(pdu);
+            else
+            {
+                OIC_LOG_V(ERROR,TAG,"Failed to generate multicast PDU");
+            }
+        }
+        else
+        {
+            OIC_LOG_V(ERROR, TAG, "request info is empty");
         }
     }
 
index b1567ec..19ea3c0 100644 (file)
@@ -105,6 +105,7 @@ static void CAProcessData(const CAData_t *data)
 
     if (SEND_TYPE_UNICAST == type)
     {
+        OIC_LOG(DEBUG,TAG,"Unicast Message");
         coap_pdu_t *pdu = NULL;
 
         if (NULL != data->requestInfo)
@@ -122,6 +123,7 @@ static void CAProcessData(const CAData_t *data)
         else
         {
             OIC_LOG(DEBUG, TAG, "request info, response info is empty");
+            return;
         }
 
         // interface controller function call.
@@ -148,29 +150,46 @@ static void CAProcessData(const CAData_t *data)
 
             coap_delete_pdu(pdu);
         }
+        else
+        {
+            OIC_LOG_V(ERROR,TAG,"Failed to Generate Unicast PDU");
+            return;
+        }
     }
     else if (SEND_TYPE_MULTICAST == type)
     {
-        OIC_LOG(DEBUG, TAG, "both requestInfo & responseInfo is not available");
+        OIC_LOG(DEBUG,TAG,"Multicast Message");
+        if (NULL != data->requestInfo)
+        {
+            OIC_LOG(DEBUG, TAG, "reqInfo avlbl");
 
-        CAInfo_t *info = &data->requestInfo->info;
+            CAInfo_t *info = &data->requestInfo->info;
 
-        info->options = data->options;
-        info->numOptions = data->numOptions;
+            info->options = data->options;
+            info->numOptions = data->numOptions;
 
-        coap_pdu_t *pdu = (coap_pdu_t *)CAGeneratePDU(CA_GET, info);
+            coap_pdu_t *pdu = (coap_pdu_t *)CAGeneratePDU(CA_GET, info);
 
-        if (NULL != pdu)
-        {
-            CALogPDUInfo(pdu);
-            res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
-            if(CA_STATUS_OK != res)
+            if (NULL != pdu)
             {
-                OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+                CALogPDUInfo(pdu);
+                res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+                if(CA_STATUS_OK != res)
+                {
+                    OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+                    coap_delete_pdu(pdu);
+                    return;
+                }
                 coap_delete_pdu(pdu);
-                return;
             }
-            coap_delete_pdu(pdu);
+            else
+            {
+                OIC_LOG(ERROR,TAG,"Failed to Generate Multicast PDU");
+            }
+        }
+        else
+        {
+            OIC_LOG(ERROR,TAG,"requestInfo is empty");
         }
     }