Prevent restore of doxm/pstat resource
authorAshwini Kumar <k.ashwini@samsung.com>
Wed, 27 Jul 2016 04:57:15 +0000 (10:27 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 27 Jul 2016 08:24:17 +0000 (08:24 +0000)
in case of owned status and retransmission.

[Patch #1] : initial upload
[Patch #2] : Update pstat resource same as doxm/cred

Change-Id: I33dbf272753ef79ad4f79c62296154500dc67e14
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9273
Reviewed-by: Joonghwan Lee <jh05.lee@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
Signed-off-by: Ashwini Kumar <k.ashwini@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9753

resource/csdk/security/src/credresource.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/pstatresource.c

index 3d3039d..724cde9 100644 (file)
@@ -1089,12 +1089,20 @@ static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * eh
                   * If some error is occured while ownership transfer,
                   * ownership transfer related resource should be revert back to initial status.
                   */
-                if(previousMsgId != ehRequest->messageID)
+                const OicSecDoxm_t* doxm =  GetDoxmResourceData();
+                if(doxm)
                 {
-                    OIC_LOG(WARNING, TAG, "The operation failed during handle DOXM request,"\
-                                        "DOXM will be reverted.");
-                    RestoreDoxmToInitState();
-                    RestorePstatToInitState();
+                    if(!doxm->owned && previousMsgId != ehRequest->messageID)
+                    {
+                        OIC_LOG(WARNING, TAG, "The operation failed during handle DOXM request,"\
+                                            "DOXM will be reverted.");
+                        RestoreDoxmToInitState();
+                        RestorePstatToInitState();
+                    }
+                }
+                else
+                {
+                    OIC_LOG(ERROR, TAG, "Invalid DOXM resource");
                 }
             }
         }
index 92fdc48..cafdd22 100644 (file)
@@ -859,8 +859,6 @@ exit:
         {
             if(!gDoxm->owned && previousMsgId != ehRequest->messageID)
             {
-                OIC_LOG(WARNING, TAG, "The operation failed during handle DOXM request,"\
-                                    "DOXM will be reverted.");
                 RestoreDoxmToInitState();
                 RestorePstatToInitState();
             }
index 796bde9..4c71325 100644 (file)
@@ -529,7 +529,6 @@ static OCEntityHandlerResult HandlePstatPostRequest(const OCEntityHandlerRequest
          prevMsgId = ehRequest->messageID;
      }
 
-
     // Send response payload to request originator
     ehRet = ((SendSRMResponse(ehRequest, ehRet, NULL, 0)) == OC_STACK_OK) ?
                    OC_EH_OK : OC_EH_ERROR;