When consumer discover already discovered provider as unsubscribing,
does not callback to upper layer before,
but we decide to callback to upper layer, so related logic is updated.
Change-Id: Iddeb4577f94f941473452ad035949aaf7c135914
Signed-off-by: KIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11499
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
NSProvider_internal * providerCacheDataFromAddr
= NSFindProviderFromAddr(provider->connection->addr);
NSProvider_internal * providerCacheDataFromAddr
= NSFindProviderFromAddr(provider->connection->addr);
- NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(
- (providerCacheDataFromAddr == NULL) ? (void *)1 : NULL,
- NSRemoveProvider_internal(providerCacheDataFromAddr));
+
+ if (providerCacheDataFromAddr)
+ {
+ if (!strcmp(providerCacheDataFromAddr->providerId, provider->providerId))
+ {
+ NSProviderConnectionInfo * infos = providerCacheDataFromAddr->connection;
+ while (infos)
+ {
+ isSubscribing |= infos->isSubscribing;
+ infos = infos->next;
+ }
+
+ if (isSubscribing == false)
+ {
+ NSProvider * providerForCb = NSCopyProvider(providerCacheDataFromAddr);
+ NSProviderChanged(providerForCb, NS_DISCOVERED);
+ NSRemoveProvider(providerForCb);
+ }
+ NSRemoveProvider_internal(providerCacheDataFromAddr);
+ return ;
+ }
+ NSRemoveProvider_internal(providerCacheDataFromAddr);
+ }
NSProvider_internal * providerCacheData = NSProviderCacheFind(provider->providerId);
NSProvider_internal * providerCacheData = NSProviderCacheFind(provider->providerId);
NS_LOG(DEBUG, "accepter is NS_ACCEPTER_CONSUMER, Callback to user");
NSProvider * providerForCb = NSCopyProvider(provider);
NSProviderChanged(providerForCb, NS_DISCOVERED);
NS_LOG(DEBUG, "accepter is NS_ACCEPTER_CONSUMER, Callback to user");
NSProvider * providerForCb = NSCopyProvider(provider);
NSProviderChanged(providerForCb, NS_DISCOVERED);
+ NSRemoveProvider(providerForCb);