Modify bug which is related provider copy issue
authorYounghyunJoo <yh_.joo@samsung.com>
Tue, 30 Aug 2016 05:32:03 +0000 (14:32 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 31 Aug 2016 07:14:21 +0000 (07:14 +0000)
some APIs which is received NSProvider pointer as an API parameter
after calling and Processing these APIs, NSProvider was removed.
to prevent this problem, as a first step in the API, we added the logic to copy provider.

Change-Id: I3523691ec4992dc9dbf0b0824a4e2ff4df133568
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11107
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/src/consumer/NSConsumerInterface.c

index e4a532862d4f9c10d59dda702705e0f4c8820751..2016a8bf0a316317409e70f10e4753af05e4ed08 100644 (file)
@@ -86,7 +86,10 @@ NSResult NSSubscribe(NSProvider * provider)
     bool isStartedConsumer = NSIsStartedConsumer();
     NS_VERIFY_NOT_NULL(isStartedConsumer == true ? (void *) 1 : NULL, NS_ERROR);
 
-    NSTask * subscribeTask = NSMakeTask(TASK_CONSUMER_REQ_SUBSCRIBE, (void *) provider);
+    NSProvider * prov = (NSProvider *)NSCopyProvider((NSProvider_internal *) provider);
+    NS_VERIFY_NOT_NULL(prov, NS_ERROR);
+
+    NSTask * subscribeTask = NSMakeTask(TASK_CONSUMER_REQ_SUBSCRIBE, (void *) prov);
     NS_VERIFY_NOT_NULL(subscribeTask, NS_ERROR);
 
     return NSConsumerPushEvent(subscribeTask);
@@ -97,7 +100,10 @@ NSResult NSUnsubscribe(NSProvider * provider)
     bool isStartedConsumer = NSIsStartedConsumer();
     NS_VERIFY_NOT_NULL(isStartedConsumer == true ? (void *) 1 : NULL, NS_ERROR);
 
-    NSTask * unsubscribeTask = NSMakeTask(TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL, (void *) provider);
+    NSProvider * prov = (NSProvider *)NSCopyProvider((NSProvider_internal *) provider);
+    NS_VERIFY_NOT_NULL(prov, NS_ERROR);
+
+    NSTask * unsubscribeTask = NSMakeTask(TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL, (void *) prov);
     NS_VERIFY_NOT_NULL(unsubscribeTask, NS_ERROR);
 
     return NSConsumerPushEvent(unsubscribeTask);
@@ -172,10 +178,12 @@ NSResult NSConsumerGetInterestTopics(NSProvider * provider)
     NS_VERIFY_NOT_NULL(prov, NS_ERROR);
     NSSelector selector = prov->accessPolicy;
     NSRemoveProvider_internal(prov);
-
     NS_VERIFY_NOT_NULL(selector == NS_SELECTION_CONSUMER ? (void *) 1 : NULL, NS_ERROR);
 
-    NSTask * topicTask = NSMakeTask(TASK_CONSUMER_GET_TOPIC_LIST, (void *) provider);
+    prov = (NSProvider *)NSCopyProvider((NSProvider_internal *) provider);
+    NS_VERIFY_NOT_NULL(prov, NS_ERROR);
+
+    NSTask * topicTask = NSMakeTask(TASK_CONSUMER_GET_TOPIC_LIST, (void *) prov);
     NS_VERIFY_NOT_NULL(topicTask, NS_ERROR);
 
     return NSConsumerPushEvent(topicTask);
@@ -196,8 +204,11 @@ NSResult NSConsumerSelectInterestTopics(NSProvider * provider)
     NSRemoveProvider_internal(prov);
     NS_VERIFY_NOT_NULL(selector == NS_SELECTION_CONSUMER ? (void *) 1 : NULL, NS_ERROR);
 
-    NSTask * topicTask = NSMakeTask(TASK_CONSUMER_SELECT_TOPIC_LIST, (void *) provider);
-    NS_VERIFY_NOT_NULL(provider, NS_ERROR);
+    prov = (NSProvider *)NSCopyProvider((NSProvider_internal *) provider);
+    NS_VERIFY_NOT_NULL(prov, NS_ERROR);
+
+    NSTask * topicTask = NSMakeTask(TASK_CONSUMER_SELECT_TOPIC_LIST, (void *) prov);
+    NS_VERIFY_NOT_NULL(topicTask, NS_ERROR);
 
     return NSConsumerPushEvent(topicTask);
 }