From dc6df8c27336490bc3bab9e02a2b80e874b27967 Mon Sep 17 00:00:00 2001 From: KIM JungYong Date: Tue, 17 Jan 2017 14:21:45 +0900 Subject: [PATCH] Fix for multiple discovery paylod in response. When consumer do discovery request to cloud, cloud server can response on multiple device's result by one of response. consumer service does not handle multiple discovery payload befour. When applying this changes, consumer service can handle multiple discovery payloads. Change-Id: I516ac933daf435b436158ae4983f0ffedefe32c0 Signed-off-by: KIM JungYong Reviewed-on: https://gerrit.iotivity.org/gerrit/16469 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../src/consumer/NSConsumerDiscovery.c | 48 ++++++++++++---------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/service/notification/src/consumer/NSConsumerDiscovery.c b/service/notification/src/consumer/NSConsumerDiscovery.c index baed182..5b6a070 100644 --- a/service/notification/src/consumer/NSConsumerDiscovery.c +++ b/service/notification/src/consumer/NSConsumerDiscovery.c @@ -107,32 +107,38 @@ OCStackApplicationResult NSProviderDiscoverListener( return OC_STACK_DELETE_TRANSACTION; } - OCResourcePayload * resource = ((OCDiscoveryPayload *)clientResponse->payload)->resources; - NS_LOG_V(DEBUG, "Discovered resource uri : %s", - resource->uri); - while (resource) + OCDiscoveryPayload * discoveryPayload = (OCDiscoveryPayload *)clientResponse->payload; + + while (discoveryPayload) { - NS_VERIFY_NOT_NULL(resource->uri, OC_STACK_KEEP_TRANSACTION); - if (strstr(resource->uri, NS_RESOURCE_URI)) + OCResourcePayload * resource = discoveryPayload->resources; + NS_LOG_V(DEBUG, "Discovered resource uri : %s", resource->uri); + while (resource) { - OCConnectivityType type = CT_DEFAULT; - if (clientResponse->addr->adapter == OC_ADAPTER_TCP) + NS_VERIFY_NOT_NULL(resource->uri, OC_STACK_KEEP_TRANSACTION); + if (strstr(resource->uri, NS_RESOURCE_URI)) { - type = CT_ADAPTER_TCP; + NS_LOG_V(DEBUG, "Request GET to provider : %s", resource->uri); + OCConnectivityType type = CT_DEFAULT; + if (clientResponse->addr->adapter == OC_ADAPTER_TCP) + { + type = CT_ADAPTER_TCP; + } + + OCDevAddr * addr = clientResponse->addr; + if (resource->secure) + { + addr->port = resource->port; + addr->flags |= OC_FLAG_SECURE; + } + + NSInvokeRequest(NULL, OC_REST_GET, addr, + resource->uri, NULL, NSIntrospectProvider, ctx, + NULL, type); } - - OCDevAddr * addr = clientResponse->addr; - if (resource->secure) - { - addr->port = resource->port; - addr->flags |= OC_FLAG_SECURE; - } - - NSInvokeRequest(NULL, OC_REST_GET, addr, - resource->uri, NULL, NSIntrospectProvider, ctx, - NULL, type); + resource = resource->next; } - resource = resource->next; + discoveryPayload = discoveryPayload->next; } return OC_STACK_KEEP_TRANSACTION; -- 2.7.4