Update snapshot(2017-10-11) 43/155143/1
authorHongkuk, Son <hongkuk.son@samsung.com>
Thu, 12 Oct 2017 06:55:24 +0000 (15:55 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Thu, 12 Oct 2017 06:56:03 +0000 (15:56 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I0682f26c3c6d0989210a8b7ddfac1485cc10671b

packaging/snapshot_history.txt
resource/c_common/ocrandom/src/ocrandom.c
resource/csdk/security/src/doxmresource.c
resource/csdk/stack/include/internal/ocobserve.h
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocstack.c
resource/provisioning/src/OCProvisioningManager.cpp
service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp

index baf3b59..dea2a26 100755 (executable)
@@ -1,3 +1,9 @@
+http://suprem.sec.samsung.net/jira/browse/CONPRO-1105
+
+commit_info_2017-10-11.txt
+
+commit_id: 2098cc76ea826cf86dddefe0b3a4833ed98f2368
+----------------------------------------------------------------------------------------------------------------------------------
 http://suprem.sec.samsung.net/jira/browse/CONPRO-1102
 
 commit_info_2017-10-04-rev1.txt
index e0dcdc5..631906c 100644 (file)
@@ -264,34 +264,33 @@ OCRandomUuidResult OCGenerateUuid(uint8_t uuid[UUID_SIZE])
     char uuidString[UUID_STRING_SIZE];
     int8_t ret = OCGenerateUuidString(uuidString);
 
-    if (ret < 0)
+    if (RAND_UUID_OK == ret)
     {
-        return ret;
-    }
+        uuid[ 0] = parseUuidPart(&uuidString[0]);
+        uuid[ 1] = parseUuidPart(&uuidString[2]);
+        uuid[ 2] = parseUuidPart(&uuidString[4]);
+        uuid[ 3] = parseUuidPart(&uuidString[6]);
 
-    uuid[ 0] = parseUuidPart(&uuidString[0]);
-    uuid[ 1] = parseUuidPart(&uuidString[2]);
-    uuid[ 2] = parseUuidPart(&uuidString[4]);
-    uuid[ 3] = parseUuidPart(&uuidString[6]);
+        uuid[ 4] = parseUuidPart(&uuidString[9]);
+        uuid[ 5] = parseUuidPart(&uuidString[11]);
 
-    uuid[ 4] = parseUuidPart(&uuidString[9]);
-    uuid[ 5] = parseUuidPart(&uuidString[11]);
+        uuid[ 6] = parseUuidPart(&uuidString[14]);
+        uuid[ 7] = parseUuidPart(&uuidString[16]);
 
-    uuid[ 6] = parseUuidPart(&uuidString[14]);
-    uuid[ 7] = parseUuidPart(&uuidString[16]);
+        uuid[ 8] = parseUuidPart(&uuidString[19]);
+        uuid[ 9] = parseUuidPart(&uuidString[21]);
 
-    uuid[ 8] = parseUuidPart(&uuidString[19]);
-    uuid[ 9] = parseUuidPart(&uuidString[21]);
+        uuid[10] = parseUuidPart(&uuidString[24]);
+        uuid[11] = parseUuidPart(&uuidString[26]);
+        uuid[12] = parseUuidPart(&uuidString[28]);
+        uuid[13] = parseUuidPart(&uuidString[30]);
+        uuid[14] = parseUuidPart(&uuidString[32]);
+        uuid[15] = parseUuidPart(&uuidString[34]);
 
-    uuid[10] = parseUuidPart(&uuidString[24]);
-    uuid[11] = parseUuidPart(&uuidString[26]);
-    uuid[12] = parseUuidPart(&uuidString[28]);
-    uuid[13] = parseUuidPart(&uuidString[30]);
-    uuid[14] = parseUuidPart(&uuidString[32]);
-    uuid[15] = parseUuidPart(&uuidString[34]);
-
-    return RAND_UUID_OK;
-#elif defined(HAVE_UUID_UUID_H)
+        return RAND_UUID_OK;
+    }
+#endif
+#if defined(HAVE_UUID_UUID_H)
     // note: uuid_t is typedefed as unsigned char[16] on linux/apple
     uuid_generate(uuid);
     return RAND_UUID_OK;
index 43aeb54..6ee4b26 100644 (file)
@@ -116,6 +116,7 @@ static OicSecDoxm_t gDefaultDoxm =
 static uint16_t gConfirmMsgId = 0;
 static ConfirmState_t gConfirmState = CONFIRM_STATE_READY;
 
+static uint8_t gEmptyUuid[UUID_LENGTH] = {0};
 
 /**
  * This method is internal method.
@@ -2049,8 +2050,9 @@ OCStackResult SetDoxmDeviceID(const OicUuid_t *deviceID)
 
 #ifdef __WITH_DTLS__
     //for normal device.
-    if (true == gDoxm->owned &&
-        memcmp(gDoxm->deviceID.id, gDoxm->owner.id, sizeof(gDoxm->owner.id)) != 0)
+    if (true == gDoxm->owned
+            && memcmp(gEmptyUuid, gDoxm->owner.id, sizeof(gDoxm->owner.id)) != 0
+            && memcmp(gDoxm->deviceID.id, gDoxm->owner.id, sizeof(gDoxm->owner.id)) != 0)
     {
         OIC_LOG(ERROR, TAG, "This device owned by owner's device.");
         OIC_LOG(ERROR, TAG, "Device UUID cannot be changed to guarantee the reliability of the connection.");
@@ -2177,7 +2179,7 @@ OCStackResult SetMOTStatus(bool enable)
     bool isDeallocateRequired = false;
 
     VERIFY_NON_NULL(TAG, gDoxm, ERROR);
-    
+
     if (NULL == gDoxm->mom && !enable)
     {
         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
index 284cfba..b057497 100644 (file)
@@ -96,6 +96,18 @@ typedef struct ResourceObserver
 
 } ResourceObserver;
 
+/**
+ *  Initialize observer list.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult InitializeObseverList();
+
+/**
+ *  Terminate observer list.
+ */
+void TerminateObserverList();
+
 #ifdef WITH_PRESENCE
 /**
  * Create an observe response and send to all observers in the observe list.
@@ -208,6 +220,7 @@ OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr);
  * @param tokenLength      Length of token.
  *
  * @return Pointer to found observer.
+ * This is copy of observer, caller must release its memory using FreeObserver().
  */
 ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLength);
 
@@ -217,10 +230,20 @@ ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLen
  * @param observeId        Observer ID to search for.
  *
  * @return Pointer to found observer.
+ * This is copy of observer, caller must release its memory using FreeObserver().
  */
 ResourceObserver* GetObserverUsingId (const OCObservationId observeId);
 
 /**
+ * Search the list of observers for the specified observe ID.
+ *
+ * @param observeId        Observer ID to search for.
+ *
+ * @return true if observer found matched with observer ID, otherwise false.
+ */
+bool IsObserverAvailable (const OCObservationId observeId);
+
+/**
  *  Add observe header option to a request.
  *
  * @param caHdrOpt        Target request CA header option.
@@ -255,5 +278,12 @@ GetObserveHeaderOption (uint32_t * observationOption,
                         CAHeaderOption_t *options,
                         uint8_t * numOptions);
 
+/**
+ *  Free memory associated with observer.
+ *
+ * @param obsNode        Observer to be freed.
+ */
+void FreeObserver (ResourceObserver* obsNode);
+
 #endif //OC_OBSERVE_H
 
index 9cc6557..d2cc07c 100644 (file)
@@ -29,6 +29,7 @@
 #include "oic_string.h"
 #include "ocpayload.h"
 #include "ocserverrequest.h"
+#include "octhread.h"
 #include "logger.h"
 
 #include <coap/utlist.h>
 #define VERIFY_NON_NULL(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
 
 static struct ResourceObserver * g_serverObsList = NULL;
+static oc_mutex g_serverObsListMutex = NULL;
+
+static ResourceObserver* GetObserverUsingIdAsOwner (const OCObservationId observeId);
+
+static ResourceObserver* CloneObserverNode (ResourceObserver* observer)
+{
+    ResourceObserver* dupObsNode = NULL;
+    if (observer)
+    {
+        dupObsNode = (ResourceObserver *) OICCalloc(1, sizeof(ResourceObserver));
+        VERIFY_NON_NULL(dupObsNode);
+        memcpy(dupObsNode, observer, sizeof(ResourceObserver));
+
+        if (observer->resUri)
+        {
+            dupObsNode->resUri = OICStrdup(observer->resUri);
+            VERIFY_NON_NULL(dupObsNode->resUri);
+        }
+
+        if (observer->query)
+        {
+            dupObsNode->query = OICStrdup(observer->query);
+            VERIFY_NON_NULL(dupObsNode->query);
+        }
+
+        if (observer->token)
+        {
+            dupObsNode->token = (CAToken_t)OICMalloc(observer->tokenLength);
+            VERIFY_NON_NULL(dupObsNode->token);
+            memcpy(dupObsNode->token, observer->token, observer->tokenLength);
+        }
+
+        dupObsNode->next = NULL;
+    }
+
+    return dupObsNode;
+
+exit:
+    FreeObserver(dupObsNode);
+    return NULL;
+}
+
+static void FreeObserverList (ResourceObserver* list)
+{
+    ResourceObserver* head = list;
+    ResourceObserver* del = NULL;
+    while (NULL != head)
+    {
+        del = head;
+        head = head->next;
+
+        OICFree(del->resUri);
+        OICFree(del->query);
+        OICFree(del->token);
+        OICFree(del);
+    }
+}
+
+static ResourceObserver* CloneObserverList (ResourceObserver* obsList)
+{
+    ResourceObserver* dupList = NULL;
+    ResourceObserver* out = NULL;
+
+    LL_FOREACH(obsList, out)
+    {
+        ResourceObserver *obsNode = CloneObserverNode(out);
+        if (NULL == obsNode)
+        {
+            FreeObserverList(dupList);
+            dupList = NULL;
+            break;
+        }
+
+        LL_APPEND(dupList, obsNode);
+    }
+
+    return dupList;
+}
+
 /**
  * Determine observe QOS based on the QOS of the request.
  * The qos passed as a parameter overrides what the client requested.
@@ -172,14 +252,14 @@ OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr,
     }
 
     OCStackResult result = OC_STACK_ERROR;
-    ResourceObserver * resourceObserver = g_serverObsList;
+    ResourceObserver * resourceObserver = NULL;
     uint8_t numObs = 0;
     OCServerRequest * request = NULL;
-    OCEntityHandlerRequest ehRequest = {0};
-    OCEntityHandlerResult ehResult = OC_EH_ERROR;
     bool observeErrorFlag = false;
 
     // Find clients that are observing this resource
+    oc_mutex_lock(g_serverObsListMutex);
+    resourceObserver = g_serverObsList;
     while (resourceObserver)
     {
         if (resourceObserver->resource == resPtr)
@@ -214,6 +294,7 @@ OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr,
 
                     if (!presenceResBuf)
                     {
+                        oc_mutex_unlock(g_serverObsListMutex);
                         return OC_STACK_NO_MEMORY;
                     }
 
@@ -243,6 +324,8 @@ OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr,
         resourceObserver = resourceObserver->next;
     }
 
+    oc_mutex_unlock(g_serverObsListMutex);
+
     if (numObs == 0)
     {
         OIC_LOG(INFO, TAG, "Resource has no observers");
@@ -278,7 +361,8 @@ OCStackResult SendListObserverNotification (OCResource * resource,
     OIC_LOG(INFO, TAG, "Entering SendListObserverNotification");
     while(numIds)
     {
-        observer = GetObserverUsingId (*obsIdList);
+        oc_mutex_lock(g_serverObsListMutex);
+        observer = GetObserverUsingIdAsOwner (*obsIdList);
         if (observer)
         {
             // Found observer - verify if it matches the resource handle
@@ -304,6 +388,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                         if (!ehResponse.payload)
                         {
                             FindAndDeleteServerRequest(request);
+                            oc_mutex_unlock(g_serverObsListMutex);
                             continue;
                         }
                         memcpy(ehResponse.payload, payload, sizeof(*payload));
@@ -334,6 +419,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                         FindAndDeleteServerRequest(request);
                     }
                 }
+
                 // Since we are in a loop, set an error flag to indicate
                 // at least one error occurred.
                 if (result != OC_STACK_OK)
@@ -342,6 +428,8 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                 }
             }
         }
+
+        oc_mutex_unlock(g_serverObsListMutex);
         obsIdList++;
         numIds--;
     }
@@ -363,7 +451,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
 
 OCStackResult GenerateObserverId (OCObservationId *observationId)
 {
-    ResourceObserver *resObs = NULL;
+    bool found = false;
 
     OIC_LOG(INFO, TAG, "Entering GenerateObserverId");
     VERIFY_NON_NULL (observationId);
@@ -375,8 +463,8 @@ OCStackResult GenerateObserverId (OCObservationId *observationId)
             *observationId = OCGetRandomByte();
         } while (0 == *observationId); //Make sure *observationId is not 0
         // Check if observation Id already exists
-        resObs = GetObserverUsingId (*observationId);
-    } while (NULL != resObs);
+        found = IsObserverAvailable (*observationId);
+    } while (found);
 
     OIC_LOG_V(INFO, TAG, "GeneratedObservation ID is %u", *observationId);
 
@@ -449,7 +537,9 @@ OCStackResult AddObserver (const char         *resUri,
             obsNode->TTL = GetTicks(MAX_OBSERVER_TTL_SECONDS * MILLISECONDS_PER_SECOND);
         }
 
+        oc_mutex_lock(g_serverObsListMutex);
         LL_APPEND (g_serverObsList, obsNode);
+        oc_mutex_unlock(g_serverObsListMutex);
 
         return OC_STACK_OK;
     }
@@ -495,6 +585,28 @@ ResourceObserver* GetObserverUsingId (const OCObservationId observeId)
 
     if (observeId)
     {
+        oc_mutex_lock(g_serverObsListMutex);
+        LL_FOREACH (g_serverObsList, out)
+        {
+            if (out->observeId == observeId)
+            {
+                oc_mutex_unlock(g_serverObsListMutex);
+                return CloneObserverNode(out);
+            }
+            CheckTimedOutObserver(out);
+        }
+        oc_mutex_unlock(g_serverObsListMutex);
+    }
+    OIC_LOG(INFO, TAG, "Observer node not found!!");
+    return NULL;
+}
+
+static ResourceObserver* GetObserverUsingIdAsOwner (const OCObservationId observeId)
+{
+    ResourceObserver *out = NULL;
+
+    if (observeId)
+    {
         LL_FOREACH (g_serverObsList, out)
         {
             if (out->observeId == observeId)
@@ -508,6 +620,27 @@ ResourceObserver* GetObserverUsingId (const OCObservationId observeId)
     return NULL;
 }
 
+bool IsObserverAvailable (const OCObservationId observeId)
+{
+    ResourceObserver *out = NULL;
+
+    if (observeId)
+    {
+        oc_mutex_lock(g_serverObsListMutex);
+        LL_FOREACH (g_serverObsList, out)
+        {
+            if (out->observeId == observeId)
+            {
+                oc_mutex_unlock(g_serverObsListMutex);
+                return true;
+            }
+        }
+        oc_mutex_unlock(g_serverObsListMutex);
+    }
+
+    return false;
+}
+
 ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLength)
 {
     if (token)
@@ -516,6 +649,38 @@ ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLen
         OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
 
         ResourceObserver *out = NULL;
+        oc_mutex_lock(g_serverObsListMutex);
+        LL_FOREACH (g_serverObsList, out)
+        {
+            /* de-annotate below line if want to see all token in cbList */
+            //OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
+            if ((memcmp(out->token, token, tokenLength) == 0))
+            {
+                OIC_LOG(INFO, TAG, "Found in observer list");
+                oc_mutex_unlock(g_serverObsListMutex);
+                return CloneObserverNode(out);
+            }
+            CheckTimedOutObserver(out);
+        }
+        oc_mutex_unlock(g_serverObsListMutex);
+    }
+    else
+    {
+        OIC_LOG(ERROR, TAG, "Passed in NULL token");
+    }
+
+    OIC_LOG(INFO, TAG, "Observer node not found!!");
+    return NULL;
+}
+
+static ResourceObserver* GetObserverUsingTokenAsOwner (const CAToken_t token, uint8_t tokenLength)
+{
+    if (token)
+    {
+        OIC_LOG(INFO, TAG, "Looking for token");
+        OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+
+        ResourceObserver *out = NULL;
         LL_FOREACH (g_serverObsList, out)
         {
             /* de-annotate below line if want to see all token in cbList */
@@ -544,17 +709,18 @@ OCStackResult DeleteObserverUsingToken (CAToken_t token, uint8_t tokenLength)
         return OC_STACK_INVALID_PARAM;
     }
 
-    ResourceObserver *obsNode = GetObserverUsingToken (token, tokenLength);
+    oc_mutex_lock(g_serverObsListMutex);
+    ResourceObserver *obsNode = GetObserverUsingTokenAsOwner (token, tokenLength);
     if (obsNode)
     {
         OIC_LOG_V(INFO, TAG, "deleting observer id  %u with token", obsNode->observeId);
         OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, tokenLength);
+
         LL_DELETE (g_serverObsList, obsNode);
-        OICFree(obsNode->resUri);
-        OICFree(obsNode->query);
-        OICFree(obsNode->token);
-        OICFree(obsNode);
+        FreeObserver(obsNode);
     }
+    oc_mutex_unlock(g_serverObsListMutex);
+
     // it is ok if we did not find the observer...
     return OC_STACK_OK;
 }
@@ -566,9 +732,13 @@ OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr)
         return OC_STACK_INVALID_PARAM;
     }
 
+    oc_mutex_lock(g_serverObsListMutex);
+    ResourceObserver* obsDupList = CloneObserverList(g_serverObsList);
+    oc_mutex_unlock(g_serverObsListMutex);
+
     ResourceObserver *out = NULL;
     ResourceObserver *tmp = NULL;
-    LL_FOREACH_SAFE(g_serverObsList, out, tmp)
+    LL_FOREACH_SAFE(obsDupList, out, tmp)
     {
         if (out)
         {
@@ -582,21 +752,29 @@ OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr)
         }
     }
 
+    FreeObserverList(obsDupList);
     return OC_STACK_OK;
 }
 
 void DeleteObserverList()
 {
-    ResourceObserver *out = NULL;
-    ResourceObserver *tmp = NULL;
-    LL_FOREACH_SAFE (g_serverObsList, out, tmp)
+    oc_mutex_lock(g_serverObsListMutex);
+
+    ResourceObserver* head = g_serverObsList;
+    ResourceObserver* del = NULL;
+    while (NULL != head)
     {
-        if (out)
-        {
-            DeleteObserverUsingToken ((out->token), out->tokenLength);
-        }
+        del = head;
+        head = head->next;
+
+        OIC_LOG_V(INFO, TAG, "deleting observer id  %u with token", del->observeId);
+        OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)del->token, del->tokenLength);
+
+        FreeObserver(del);
     }
+
     g_serverObsList = NULL;
+    oc_mutex_unlock(g_serverObsListMutex);
 }
 
 /*
@@ -685,3 +863,41 @@ GetObserveHeaderOption (uint32_t * observationOption,
     return OC_STACK_OK;
 }
 
+OCStackResult InitializeObseverList()
+{
+    OIC_LOG(DEBUG, TAG, "InitializeObseverList IN");
+
+    if (NULL == g_serverObsListMutex)
+    {
+        g_serverObsListMutex = oc_mutex_new();
+    }
+
+    OIC_LOG(DEBUG, TAG, "InitializeObseverList OUT");
+    return OC_STACK_OK;
+}
+
+void TerminateObserverList()
+{
+    OIC_LOG(DEBUG, TAG, "TerminateObserverList IN");
+
+    DeleteObserverList();
+
+    if (NULL != g_serverObsListMutex)
+    {
+        oc_mutex_free(g_serverObsListMutex);
+        g_serverObsListMutex = NULL;
+    }
+
+    OIC_LOG(DEBUG, TAG, "TerminateObserverList OUT");
+}
+
+void FreeObserver (ResourceObserver* obsNode)
+{
+    if (NULL != obsNode)
+    {
+        OICFree(obsNode->resUri);
+        OICFree(obsNode->query);
+        OICFree(obsNode->token);
+        OICFree(obsNode);
+    }
+}
index 16579f8..d6ec143 100755 (executable)
@@ -1225,6 +1225,7 @@ HandleResourceWithEntityHandler(OCServerRequest *request,
             // Since we are making an early return and not responding, the server request
             // needs to be deleted.
             FindAndDeleteServerRequest (request);
+            FreeObserver(obs);
             return OC_STACK_OK;
         }
 
@@ -1314,6 +1315,7 @@ HandleResourceWithEntityHandler(OCServerRequest *request,
     result = EntityHandlerCodeToOCStackCode(ehResult);
 exit:
     OCPayloadDestroy(ehRequest.payload);
+    FreeObserver(resObs);
     return result;
 }
 
index c603445..15bdaee 100644 (file)
@@ -588,6 +588,7 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
                                                 0);
             if (result != OC_STACK_OK)
             {
+                FreeObserver(observer);
                 return result;
             }
 
@@ -596,6 +597,8 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
                 observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
                                                   observer->resource->entityHandlerCallbackParam);
             }
+
+            FreeObserver(observer);
         }
 
         result = DeleteObserverUsingToken(token, tokenLength);
@@ -618,6 +621,7 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
             observer->forceHighQos = 0;
             observer->failedCommCount = 0;
             result = OC_STACK_OK;
+            FreeObserver(observer);
         }
         else
         {
@@ -644,6 +648,7 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
                                                     0);
                 if (result != OC_STACK_OK)
                 {
+                    FreeObserver(observer);
                     return OC_STACK_ERROR;
                 }
 
@@ -672,6 +677,8 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
                           observer->failedCommCount);
                 result = OC_STACK_CONTINUE;
             }
+
+            FreeObserver(observer);
         }
         break;
     default:
@@ -1339,9 +1346,6 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
     ClientCB *cbNode = GetClientCB(responseInfo->info.token,
             responseInfo->info.tokenLength, NULL, NULL);
 
-    ResourceObserver * observer = GetObserverUsingToken (responseInfo->info.token,
-            responseInfo->info.tokenLength);
-
     if(cbNode)
     {
         OIC_LOG(INFO, TAG, "There is a cbNode associated with the response token");
@@ -1680,6 +1684,9 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
         return;
     }
 
+    ResourceObserver * observer = GetObserverUsingToken (responseInfo->info.token,
+            responseInfo->info.tokenLength);
+
     if(observer)
     {
         OIC_LOG(INFO, TAG, "There is an observer associated with the response token");
@@ -1705,6 +1712,8 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             OCStackFeedBack(responseInfo->info.token, responseInfo->info.tokenLength,
                     OC_OBSERVER_FAILED_COMM);
         }
+
+        FreeObserver(observer);
         return;
     }
 
@@ -2490,6 +2499,8 @@ OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     }
 #endif
 
+    InitializeObseverList();
+
 exit:
     if(result != OC_STACK_OK)
     {
@@ -2546,7 +2557,7 @@ OCStackResult OCStop()
 
     TerminateScheduleResourceList();
     // Remove all observers
-    DeleteObserverList();
+    TerminateObserverList();
     // Free memory dynamically allocated for resources
     deleteAllResources();
     // Remove all the client callbacks
index 3c18238..b05bc2a 100644 (file)
@@ -802,20 +802,7 @@ namespace OC
             return OC_STACK_INVALID_PARAM;
         }
 
-        OCStackResult result;
-        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
-
-        if (cLock)
-        {
-            std::lock_guard<std::recursive_mutex> lock(*cLock);
-            result = SetDeviceIdSeed(seed, seedSize);
-        }
-        else
-        {
-            oclog() <<"Mutex not found";
-            result = OC_STACK_ERROR;
-        }
-        return result;
+        return SetDeviceIdSeed(seed, seedSize);
     }
 
     int OCSecure::peerCertCallbackWrapper(void *ctx, const mbedtls_x509_crt *cert,
index 941239d..7434b41 100755 (executable)
@@ -185,8 +185,17 @@ namespace OIC
                     ES_OK == status->getESResult() )
             {
                 // NOTE: Temporary patch
-                CAEndpoint_t endpoint = {.adapter = CA_ADAPTER_IP};
-
+                CAEndpoint_t endpoint = {
+                    .adapter = CA_ADAPTER_IP,
+                    .flags = CA_DEFAULT_FLAGS,
+                    .port = 0,
+                    .addr = {0},
+                    .ifindex = 0,
+                    .remoteId = {0},
+#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
+                    .routeData = {0}
+#endif
+                };
                 OCDevAddr address = m_ocResource->getDevAddr();
                 OICStrcpy(endpoint.addr, MAX_ADDR_STR_SIZE, address.addr);
                 endpoint.port = address.port;