Fix bugs about memory free at Notification scheduler, and don't initialize observe...
authorjaesick.shin <jaesick.shin@samsung.com>
Fri, 22 Jul 2016 07:51:44 +0000 (16:51 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 25 Jul 2016 07:12:07 +0000 (07:12 +0000)
This commit included bug fixed.
1. double freeing of memory int stopscheduler function.
2. The code has been cleared from the prevous commit.
   added initialize code of observeid.

second, third patch included
delete not required header and add required header.

Change-Id: I56b330ef99f6ef6b57c81afd0e75e25dfaf5306b
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9605
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/android/notification-service/src/main/jni/notificationProvider.h
service/notification/include/NSCommon.h
service/notification/src/common/NSStructs.h
service/notification/src/provider/NSProviderScheduler.c
service/notification/src/provider/NSProviderSubscription.c

index 41beb5d..e11fa79 100644 (file)
@@ -44,6 +44,8 @@
 #define NS_ATTRIBUTE_DATETIME "DATE_TIME"
 #define NS_ATTRIBUTE_TTL "TTL"
 
+#include <stdint.h>
+
 /**
  * Result code of notification service
  */
index 47e30ed..80c6706 100644 (file)
@@ -28,6 +28,7 @@
 #include <octypes.h>\r
 #include "NSCommon.h"\r
 #include "NSConstants.h"\r
+#include "ocstack.h"\r
 \r
 typedef struct _nsTask\r
 {\r
index 9e9173f..64032be 100755 (executable)
@@ -125,11 +125,10 @@ bool NSStopScheduler()
         {\r
             NSTask* temp = NSHeadMsg[i];\r
             NSHeadMsg[i] = NSHeadMsg[i]->nextTask;\r
-            NSFreeData(i, NSHeadMsg[i]);\r
+            NSFreeData(i, temp);\r
             OICFree(temp);\r
         }\r
 \r
-        OICFree(NSHeadMsg[i]);\r
         NSTailMsg[i] = NSHeadMsg[i] = NULL;\r
 \r
         pthread_mutex_unlock(&NSMutex[i]);\r
index 8ea355a..bb8d742 100644 (file)
@@ -137,15 +137,19 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
         {\r
             NS_LOG(DEBUG, "Requested by remote server");\r
             subData->remote_messageObId = entityHandlerRequest->obsInfo.obsId;\r
+            subData->messageObId = 0;\r
             NS_LOG_V(DEBUG, "SubList message observation ID = [%d]", subData->remote_messageObId);\r
         }\r
         else\r
         {\r
             NS_LOG(DEBUG, "Requested by local consumer");\r
             subData->messageObId = entityHandlerRequest->obsInfo.obsId;\r
+            subData->remote_messageObId = 0;\r
             NS_LOG_V(DEBUG, "SubList message observation ID = [%d]", subData->messageObId);\r
         }\r
         subData->isWhite = false;\r
+        subData->remote_syncObId = 0;\r
+        subData->syncObId = 0;\r
 \r
         element->data = (void*) subData;\r
         element->next = NULL;\r
@@ -180,16 +184,20 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
         {\r
             NS_LOG(DEBUG, "Requested by remote server");\r
             subData->remote_syncObId = entityHandlerRequest->obsInfo.obsId;\r
+            subData->syncObId = 0;\r
             NS_LOG_V(DEBUG, "SubList sync observation ID = [%d]", subData->remote_syncObId);\r
         }\r
         else\r
         {\r
             NS_LOG(DEBUG, "Requested by local consumer");\r
             subData->syncObId = entityHandlerRequest->obsInfo.obsId;\r
+            subData->remote_syncObId = 0;\r
             NS_LOG_V(DEBUG, "SubList sync observation ID = [%d]", subData->syncObId);\r
         }\r
 \r
         subData->isWhite = false;\r
+        subData->messageObId = 0;\r
+        subData->remote_messageObId = 0;\r
 \r
         element->data = (void*) subData;\r
         element->next = NULL;\r