Update snapshot(2017-12-06)
[platform/upstream/iotivity.git] / resource / csdk / stack / src / ocstack.c
index 15bdaee..a0e4029 100644 (file)
@@ -1276,9 +1276,9 @@ OCStackResult HandlePresenceResponse(const CAEndpoint_t *endpoint,
         }
     }
 
-    OIC_LOG(INFO, TAG, "Callback for presence");
-
+    OIC_LOG(INFO, TAG, "Before calling into application address space for presence");
     cbResult = cbNode->callBack(cbNode->context, cbNode->handle, &response);
+    OIC_LOG(INFO, TAG, "After calling into application address space for presence");
 
     if (cbResult == OC_STACK_DELETE_TRANSACTION)
     {
@@ -1378,7 +1378,6 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
         else if(responseInfo->result == CA_RETRANSMIT_TIMEOUT)
         {
             OIC_LOG(INFO, TAG, "Receiving A Timeout for this token");
-            OIC_LOG(INFO, TAG, "Calling into application address space");
 
             OCClientResponse response =
                 {.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
@@ -1390,10 +1389,12 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             response.identity.id_length = responseInfo->info.identity.id_length;
 
             response.result = CAResponseToOCStackResult(responseInfo->result);
+            OIC_LOG(INFO, TAG, "Before calling into application address space for reTrans timeout");
             cbNode->callBack(cbNode->context,
                     cbNode->handle, &response);
+            OIC_LOG(INFO, TAG, "After calling into application address space for reTrans timeout");
             FindAndDeleteClientCB(cbNode);
-            OICFree(response.resourceUri);
+            OICFree((void *)response.resourceUri);
         }
 #ifdef __TIZENRT__
         else if ((cbNode->method == OC_REST_OBSERVE || cbNode->method == OC_REST_OBSERVE_ALL)
@@ -1409,9 +1410,12 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             response.identity.id_length = responseInfo->info.identity.id_length;
             response.result = OC_STACK_UNAUTHORIZED_REQ;
 
+            OIC_LOG(INFO, TAG, "Before calling into application address space for observe resp");
             cbNode->callBack(cbNode->context,
                              cbNode->handle,
                              &response);
+            OIC_LOG(INFO, TAG, "After calling into application address space for observe resp");
+
             FindAndDeleteClientCB(cbNode);
             OICFree(response.resourceUri);
         }
@@ -1419,7 +1423,6 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
         else
         {
             OIC_LOG(INFO, TAG, "This is a regular response, A client call back is found");
-            OIC_LOG(INFO, TAG, "Calling into application address space");
 
             OCClientResponse response;
             memset(&response, 0, sizeof(OCClientResponse));
@@ -1486,7 +1489,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                     {
                         OIC_LOG_V(ERROR, TAG, "Unknown Payload type in Discovery: %d %s",
                                 cbNode->method, cbNode->requestUri);
-                        OICFree(response.resourceUri);
+                        OICFree((void *)response.resourceUri);
                         return;
                     }
                 }
@@ -1524,7 +1527,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                 {
                     OIC_LOG_V(ERROR, TAG, "Unknown Payload type: %d %s",
                             cbNode->method, cbNode->requestUri);
-                    OICFree(response.resourceUri);
+                    OICFree((void *)response.resourceUri);
                     return;
                 }
 
@@ -1538,7 +1541,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                     {
                         OIC_LOG(ERROR, TAG, "Error converting payload");
                         OCPayloadDestroy(response.payload);
-                        OICFree(response.resourceUri);
+                        OICFree((void *)response.resourceUri);
                         return;
                     }
                 }
@@ -1579,7 +1582,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                 {
                     OIC_LOG(ERROR, TAG, "#header options are more than MAX_HEADER_OPTIONS");
                     OCPayloadDestroy(response.payload);
-                    OICFree(response.resourceUri);
+                    OICFree((void *)response.resourceUri);
                     return;
                 }
 
@@ -1650,9 +1653,12 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                     HandleBatchResponse(cbNode->requestUri, (OCRepPayload **)&response.payload);
                 }
 
+                OIC_LOG(INFO, TAG, "Before calling into application address space for handleResponse");
                 OCStackApplicationResult appFeedback = cbNode->callBack(cbNode->context,
                                                                         cbNode->handle,
                                                                         &response);
+                OIC_LOG(INFO, TAG, "After calling into application address space for handleResponse");
+
                 cbNode->sequenceNumber = response.sequenceNumber;
 
                 if (appFeedback == OC_STACK_DELETE_TRANSACTION)
@@ -1678,7 +1684,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                 }
             }
 
-            OICFree(response.resourceUri);
+            OICFree((void *)response.resourceUri);
             OCPayloadDestroy(response.payload);
         }
         return;
@@ -1826,7 +1832,9 @@ void HandleCAErrorResponse(const CAEndpoint_t *endPoint, const CAErrorInfo_t *er
         response.identity.id_length = errorInfo->info.identity.id_length;
         response.result = CAResultToOCResult(errorInfo->result);
 
+        OIC_LOG(INFO, TAG, "Before calling into application address space for error response");
         cbNode->callBack(cbNode->context, cbNode->handle, &response);
+        OIC_LOG(INFO, TAG, "After calling into application address space for error response");
     }
 
     ResourceObserver *observer = GetObserverUsingToken(errorInfo->info.token,
@@ -2357,6 +2365,9 @@ OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
 
 OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags)
 {
+    OC_UNUSED(serverFlags);
+    OC_UNUSED(clientFlags);
+
     OIC_LOG(DEBUG, TAG, "call OCInit1");
     return OCInit2(mode, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS, OC_DEFAULT_ADAPTER);
 }
@@ -3335,7 +3346,10 @@ OCStackResult OCProcessPresence()
             OIC_LOG_V(DEBUG, TAG, "moving to TTL level %d",
                                         cbNode->presence->TTLlevel);
 
+            OIC_LOG(INFO, TAG, "Before calling into application address space for presence timeout");
             cbResult = cbNode->callBack(cbNode->context, cbNode->handle, &clientResponse);
+            OIC_LOG(INFO, TAG, "After calling into application address space for presence timeout");
+
             if (cbResult == OC_STACK_DELETE_TRANSACTION)
             {
                 FindAndDeleteClientCB(cbNode);
@@ -5193,8 +5207,19 @@ OCStackResult OCUpdateResourceInsWithResponse(const char *requestUri,
                                 {
                                     OCBindResourceInsToResource(handle, ins);
                                 }
+
+                                OICFree(uri);
+                                uri = NULL;
                             }
                         }
+
+                        // Free links
+                        size_t count = calcDimTotal(dimensions);
+                        for (size_t k = 0; k < count; k++)
+                        {
+                            OCRepPayloadDestroy(links[k]);
+                        }
+                        OICFree(links);
                     }
                 }
             }