[IOT-2806] patch 22855 overwritten mistakenly 49/22949/3
authorNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Fri, 20 Oct 2017 23:54:15 +0000 (16:54 -0700)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Sat, 21 Oct 2017 19:30:59 +0000 (19:30 +0000)
A recent patch over-wrote the fix to 2806 (patch 22855)
so this is just a re-creation of 22855.  However gerrit
can't figure out how to re-apply 22855, and I don't know how to
force it, so I'm just creating a new patch.

Change-Id: I5c4b67a3cdfa1f9a4368fc8f7b24203da1644524
Signed-off-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
resource/csdk/security/src/pstatresource.c

index e8c9466..89f7c91 100644 (file)
@@ -854,6 +854,19 @@ static OCEntityHandlerResult HandlePstatPostRequest(OCEntityHandlerRequest *ehRe
                 pstat->cm &= ~UPDATE_SOFTWARE; // Unset the cm bit, per spec
             }
 
+            // update om
+            gPstat->om = pstat->om;
+
+            // update tm
+            OIC_LOG_V(INFO, TAG, "%s setting gPstat->tm = %u", __func__, pstat->tm);
+            gPstat->tm = pstat->tm;
+
+            // update rownerID
+            gPstat->rownerID = pstat->rownerID;
+
+            // update dos LAST of all Properties, as changing dos can also
+            // change other Properties and we want the dos-asserted values
+            // to "stick" rather than being over-written by prior values.
             if (pstat->dos.state != gPstat->dos.state)
             {
                 OCStackResult stateChangeResult = OC_STACK_ERROR;
@@ -884,27 +897,11 @@ static OCEntityHandlerResult HandlePstatPostRequest(OCEntityHandlerRequest *ehRe
                 }
             }
 
-            // update om
-            gPstat->om = pstat->om;
-
-            // update tm
-            OIC_LOG_V(INFO, TAG, "%s setting gPstat->tm = %u", __func__, pstat->tm);
-            gPstat->tm = pstat->tm;
-
-            // set rowner and save
-            OicUuid_t prevId = {.id={0}};
-            memcpy(&prevId, &gPstat->rownerID, sizeof(OicUuid_t));
-            memcpy(&gPstat->rownerID, &pstat->rownerID, sizeof(OicUuid_t));
-
             // Convert pstat data into CBOR for update to persistent storage
             if (UpdatePersistentStorage(gPstat))
             {
                 ehRet = OC_EH_OK;
             }
-            else
-            {
-                memcpy(&gPstat->rownerID, &prevId, sizeof(OicUuid_t));
-            }
         }
     }