[CONPRO-1398] Adjust server request handling 37/208337/1
authorRobert Chudek <r.chudek@partner.samsung.com>
Tue, 12 Feb 2019 11:03:44 +0000 (12:03 +0100)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 24 Jun 2019 00:48:29 +0000 (09:48 +0900)
[Model] IoTivity
[BinType] AP
[Customer] IoT-Core

[Issue#] CONPRO-1398
[Request] Robert Chudek / r.chudek
[Occurrence Version] n/a

[Problem] IoT-Core needs some additional server request handling.
[Cause & Measure] n/a
[Checking Method] n/a

[Team] IoT Connection
[Developer] Robert Chudek / r.chudek
[Solution company] Samsung
[Change Type] adjustment

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/735a165c3239cfc5e0b01cd2ef1b5843321d3edb
(cherry picked from 735a165c3239cfc5e0b01cd2ef1b5843321d3edb)

Change-Id: If183e682dd165c64830d71f70d74eb15a5bb82ab
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oickeepalive.c

index 3dde884..aa5930b 100644 (file)
@@ -100,6 +100,7 @@ static void DeleteServerRequest(OCServerRequest * serverRequest)
 {
     if(serverRequest)
     {
+        OIC_LOG_V(WARNING, TAG, "Server request ID = [%u]", serverRequest->requestId);
         LL_DELETE(serverRequestList, serverRequest);
         OICFree(serverRequest->requestToken);
         OICFree(serverRequest->rcvdVendorSpecificHeaderOptions);
@@ -300,6 +301,12 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
     serverRequest->numResponses = 1;
     serverRequest->requestId = OCGetRandom();
 
+    // checking same id exist
+    while(serverRequest->requestId == 0 || GetServerRequestUsingHandle(serverRequest->requestId) != NULL)
+    {
+        serverRequest->requestId = OCGetRandom();
+    }
+
     if(query)
     {
         OICStrcpy(serverRequest->query, sizeof(serverRequest->query), query);
index 63eef55..fa790d1 100644 (file)
@@ -61,6 +61,7 @@
 #include "ocpayload.h"
 #include "ocpayloadcbor.h"
 #include "cautilinterface.h"
+#include "camessagehandler.h"
 #include "oicgroup.h"
 
 #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
@@ -2014,6 +2015,8 @@ OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest)
         {
             request->requestComplete = 1;
         }
+
+        OIC_LOG_V(WARNING, TAG, "Server request ID = [%u]", request->requestId);
     }
     else
     {
index 451d9dc..bd01d08 100755 (executable)
@@ -644,8 +644,13 @@ void OCProcessKeepAlive()
                     {
                         OIC_LOG(DEBUG, TAG, "Client does not receive the response within 1 minutes.");
 
-                        // Send message to disconnect session.
-                        OCSendDisconnectMessage(entry);
+                        /* TCPDisconnectSession should be invoked depending on the result from client callback */
+                        if (OCSendDisconnectMessage(entry) == OC_STACK_CONTINUE)
+                        {
+                            // Set sentPingMsg values with false.
+                            entry->sentPingMsg = false;
+                            entry->handle = NULL;
+                        }
                     }
 #ifdef WITH_PROCESS_EVENT
                     else
@@ -714,7 +719,12 @@ OCStackResult OCSendDisconnectMessage(const KeepAliveEntry_t *entry)
         response.resourceUri = cbNode->requestUri;
         response.result = OC_STACK_TIMEOUT;
 
-        cbNode->callBack(cbNode->context, cbNode->handle, &response);
+        /* TCPDisconnectSession should be invoked depending on the result from client callback */
+        if (cbNode->callBack(cbNode->context, cbNode->handle, &response) == OC_STACK_KEEP_TRANSACTION)
+        {
+            return OC_STACK_CONTINUE;
+        }
+
         FindAndDeleteClientCB(cbNode);
     }