[IOT-1893] Delete Request Logic Fixed.
authorSushil Yadav <sushil.ky@samsung.com>
Tue, 9 May 2017 10:09:04 +0000 (15:39 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 11 May 2017 08:34:38 +0000 (08:34 +0000)
Change-Id: I0df40af7c198e3e26aa5450da3489e5876628acc
Signed-off-by: Sushil Yadav <sushil.ky@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19743
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp

index ee934d9..3489ef7 100755 (executable)
@@ -777,7 +777,11 @@ void* RequestDeleteDeathResourceTask(void* myqos)
 
     if (OC_STACK_OK != result)
     {
-        OIC_LOG(INFO, TAG, "Second DELETE call did not succeed");
+        OIC_LOG(INFO, TAG, "Second DELETE Request also failed");
+    }
+    else
+    {
+        OIC_LOG(INFO, TAG, "Second DELETE Request sent successfully; Waiting for Callback");
     }
 
     return NULL;
@@ -798,16 +802,15 @@ int InitDeleteRequest(OCQualityOfService qos)
     if (OC_STACK_OK != result)
     {
         // Error can happen if for example, network connectivity is down
-        OIC_LOG(INFO, TAG, "First DELETE call did not succeed");
-    }
-    else
-    {
+        OIC_LOG(INFO, TAG, "DELETE Request did not succeed; Will try again.");
         //Create a thread to delete this resource again
         pthread_t threadId;
         pthread_create (&threadId, NULL, RequestDeleteDeathResourceTask, (void*)qos);
     }
-
-    OIC_LOG_V(INFO, TAG, "\n\nExit  %s", __func__);
+    else
+    {
+        OIC_LOG(INFO, TAG, "DELETE Request sent successfully; Waiting for Callback");
+    }
     return result;
 }
 
index 0c11048..78bf24b 100644 (file)
@@ -369,7 +369,7 @@ OCEntityHandlerResult ProcessDeleteRequest (OCEntityHandlerRequest *ehRequest)
         if (result == OC_STACK_OK)
         {
             OIC_LOG (INFO, TAG, "\n\nDelete Resource operation succeeded.");
-            ehResult = OC_EH_OK;
+            ehResult = OC_EH_RESOURCE_DELETED;
 
             //Step 2: clear observers who wanted to observe this resource at the app level.
             for (uint8_t i = 0; i < SAMPLE_MAX_NUM_OBSERVATIONS; i++)
@@ -385,7 +385,7 @@ OCEntityHandlerResult ProcessDeleteRequest (OCEntityHandlerRequest *ehRequest)
         else if (result == OC_STACK_NO_RESOURCE)
         {
             OIC_LOG(INFO, TAG, "\n\nThe resource doesn't exist or it might have been deleted.");
-            ehResult = OC_EH_RESOURCE_DELETED;
+            ehResult = OC_EH_RESOURCE_NOT_FOUND;
         }
         else
         {
@@ -1129,7 +1129,7 @@ int main(int argc, char* argv[])
     OCSetRAInfo(&rainfo);
 #endif
 
-    
+
     OIC_LOG(DEBUG, TAG, "OCServer is starting...");
     OCPersistentStorage pstStr {
         server_fopen,