service is terminated when repeated starts and stops.
authorjaesick.shin <jaesick.shin@samsung.com>
Mon, 4 Jul 2016 04:52:50 +0000 (13:52 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 6 Jul 2016 12:03:37 +0000 (12:03 +0000)
The reason for this issue is due to deallocate the
variables that are created as char array when the nsstopprovider operating.
so, that bug is fixed.

Change-Id: I6d8fc5ca9f719b8236f9660376604ed41a04ef81
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9139
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/src/common/NSStructs.h
service/notification/src/provider/NSProviderResource.c
service/notification/src/provider/NSProviderSubscription.c
service/notification/src/provider/cache/linux/NSProviderMemoryCache.c

index adc7467..6703e01 100644 (file)
@@ -52,7 +52,7 @@ typedef struct
 \r
 typedef struct\r
 {\r
-    char * id; // ip\r
+    char id[37]; // ip\r
     int syncObId;\r
     int messageObId;\r
     bool isWhite;\r
index d9b6485..01ef948 100644 (file)
@@ -141,6 +141,10 @@ NSResult NSUnRegisterResource()
         return NS_ERROR;
     }
 
+    NotificationResource.handle = NULL;
+    NotificationMessageResource.handle = NULL;
+    NotificationSyncResource.handle = NULL;
+
     NS_LOG(DEBUG, "NSUnRegisterResource - OUT");
     return NS_OK;
 }
index 4610698..c770bca 100644 (file)
@@ -127,7 +127,7 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
         NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
         NSCacheSubData * subData = (NSCacheSubData *) OICMalloc(sizeof(NSCacheSubData));\r
 \r
-        subData->id = id;\r
+        OICStrcpy(subData->id, UUID_STRING_SIZE, id);\r
 \r
         subData->isWhite = false;\r
         subData->messageObId = entityHandlerRequest->obsInfo.obsId;\r
@@ -160,8 +160,8 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
         NS_LOG(DEBUG, "resourceType == NS_RESOURCE_SYNC");\r
         NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
         NSCacheSubData * subData = (NSCacheSubData *) OICMalloc(sizeof(NSCacheSubData));\r
+        OICStrcpy(subData->id, UUID_STRING_SIZE, id);\r
 \r
-        subData->id = id;\r
 \r
         subData->isWhite = false;\r
         subData->syncObId = entityHandlerRequest->obsInfo.obsId;\r
@@ -199,7 +199,8 @@ void NSHandleUnsubscription(OCEntityHandlerRequest *entityHandlerRequest)
 \r
     NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
     NSCacheSubData * subData = (NSCacheSubData *) OICMalloc(sizeof(NSCacheSubData));\r
-    subData->id = id;\r
+\r
+    OICStrcpy(subData->id, UUID_STRING_SIZE, id);\r
     subData->isWhite = false;\r
     subData->messageObId = entityHandlerRequest->obsInfo.obsId;\r
 \r
@@ -299,7 +300,7 @@ NSResult NSSendSubscriptionResponse(OCEntityHandlerRequest *entityHandlerRequest
         NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
         NSCacheSubData * subData = (NSCacheSubData *) OICMalloc(sizeof(NSCacheSubData));\r
 \r
-        subData->id = id;\r
+        OICStrcpy(subData->id, UUID_STRING_SIZE, id);\r
 \r
         subData->isWhite = true;\r
         subData->messageObId = entityHandlerRequest->obsInfo.obsId;\r
index 94790f8..8ce8f97 100755 (executable)
@@ -342,12 +342,8 @@ NSResult NSProviderDeleteCacheData(NSCacheType type, void * data)
     if (type == NS_PROVIDER_CACHE_SUBSCRIBER)\r
     {\r
         NSCacheSubData * subData = (NSCacheSubData *) data;\r
-        if (subData->id)\r
-        {\r
-            OICFree(subData->id);\r
-            subData->id = NULL;\r
-        }\r
 \r
+        (subData->id)[0] = '\0';\r
         OICFree(subData);\r
 \r
         return NS_OK;\r