From 8113caa86c24d2939faf1ba3c2d7985929c25981 Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 23 Mar 2017 16:44:42 +0900 Subject: [PATCH] Fix in EnableRemoteService for Notification Service via Cloud When notification message is sent thru cloud, consumer cannot receive. It worked well from initial development environment but others reported it does not worked well in some environment. Initially, to call NSSetRemoteServerAddress(char *serverAddress) resolves issue by testing but, logic perspective, this is not solution. MSCacheSubData has messageObserverID, syncObserverID for local and remote consumer respectively and this structure brings fundamental complexity inspite they are not handled separately. This patch remove remote set for these observerIDs member from struct. Change-Id: I7e5e52487d71cba0cb3c9772fd0436d8e323285e Signed-off-by: jake Reviewed-on: https://gerrit.iotivity.org/gerrit/17959 Tested-by: jenkins-iotivity Reviewed-by: JungYong KIM Reviewed-by: Uze Choi Tested-by: Uze Choi --- service/notification/src/common/NSStructs.h | 2 - .../src/provider/NSProviderInterface.c | 4 -- .../src/provider/NSProviderMemoryCache.c | 25 +----------- .../src/provider/NSProviderNotification.c | 30 -------------- .../src/provider/NSProviderSubscription.c | 46 ++++------------------ .../notification/src/provider/NSProviderSystem.c | 32 --------------- .../notification/src/provider/NSProviderSystem.h | 6 --- .../notification/src/provider/NSProviderTopic.c | 7 ---- 8 files changed, 9 insertions(+), 143 deletions(-) diff --git a/service/notification/src/common/NSStructs.h b/service/notification/src/common/NSStructs.h index 39126bc..a2e4c7b 100644 --- a/service/notification/src/common/NSStructs.h +++ b/service/notification/src/common/NSStructs.h @@ -69,8 +69,6 @@ typedef struct char id[NS_UUID_STRING_SIZE]; int syncObId; // sync resource observer ID for local consumer int messageObId; // message resource observer ID for local consumer - int remote_syncObId; //sync observer ID subscribed through remote server - int remote_messageObId; //message observer ID subscribed through remote server bool isWhite; // access state -> True: allowed / False: blocked } NSCacheSubData; diff --git a/service/notification/src/provider/NSProviderInterface.c b/service/notification/src/provider/NSProviderInterface.c index 73f3c95..64290fa 100644 --- a/service/notification/src/provider/NSProviderInterface.c +++ b/service/notification/src/provider/NSProviderInterface.c @@ -183,10 +183,6 @@ NSResult NSProviderDisableRemoteService(char *serverAddress) } NS_LOG_V(INFO_PRIVATE, "Remote server address: %s", serverAddress); - - NS_LOG(DEBUG, "Delete remote server info"); - NSDeleteRemoteServerAddress(serverAddress); - pthread_mutex_unlock(&nsInitMutex); NS_LOG(DEBUG, "NSProviderDisableRemoteService - OUT"); return NS_OK; diff --git a/service/notification/src/provider/NSProviderMemoryCache.c b/service/notification/src/provider/NSProviderMemoryCache.c index 36e35c0..fc7f5f6 100644 --- a/service/notification/src/provider/NSProviderMemoryCache.c +++ b/service/notification/src/provider/NSProviderMemoryCache.c @@ -111,8 +111,6 @@ NSResult NSCacheUpdateSubScriptionState(NSCacheList * list, char * id, bool stat NS_LOG_V(INFO_PRIVATE, "currData_ID = %s", itData->id); NS_LOG_V(DEBUG, "currData_MsgObID = %d", itData->messageObId); NS_LOG_V(DEBUG, "currData_SyncObID = %d", itData->syncObId); - NS_LOG_V(DEBUG, "currData_Cloud_MsgObID = %d", itData->remote_messageObId); - NS_LOG_V(DEBUG, "currData_Cloud_SyncObID = %d", itData->remote_syncObId); NS_LOG_V(DEBUG, "currData_IsWhite = %d", itData->isWhite); NS_LOG_V(DEBUG, "update state = %d", state); @@ -167,15 +165,11 @@ NSResult NSProviderStorageWrite(NSCacheList * list, NSCacheElement * newObj) NS_LOG_V(INFO_PRIVATE, "currData_ID = %s", itData->id); NS_LOG_V(DEBUG, "currData_MsgObID = %d", itData->messageObId); NS_LOG_V(DEBUG, "currData_SyncObID = %d", itData->syncObId); - NS_LOG_V(DEBUG, "currData_Cloud_MsgObID = %d", itData->remote_messageObId); - NS_LOG_V(DEBUG, "currData_Cloud_SyncObID = %d", itData->remote_syncObId); NS_LOG_V(DEBUG, "currData_IsWhite = %d", itData->isWhite); NS_LOG_V(INFO_PRIVATE, "subData_ID = %s", subData->id); NS_LOG_V(DEBUG, "subData_MsgObID = %d", subData->messageObId); NS_LOG_V(DEBUG, "subData_SyncObID = %d", subData->syncObId); - NS_LOG_V(DEBUG, "subData_Cloud_MsgObID = %d", subData->remote_messageObId); - NS_LOG_V(DEBUG, "subData_Cloud_SyncObID = %d", subData->remote_syncObId); NS_LOG_V(DEBUG, "subData_IsWhite = %d", subData->isWhite); if (subData->messageObId != 0) @@ -188,17 +182,6 @@ NSResult NSProviderStorageWrite(NSCacheList * list, NSCacheElement * newObj) itData->syncObId = subData->syncObId; } - if (subData->remote_messageObId != 0) - { - itData->remote_messageObId = subData->remote_messageObId; - } - - if (subData->remote_syncObId != 0) - { - itData->remote_syncObId = subData->remote_syncObId; - NS_LOG_V(DEBUG, "sync id cached: %d", itData->remote_syncObId); - } - NS_LOG(DEBUG, "Update Data - OUT"); OICFree(subData); OICFree(newObj); @@ -270,13 +253,7 @@ NSResult NSProviderStorageDestroy(NSCacheList * list) bool NSIsSameObId(NSCacheSubData * data, OCObservationId id) { - if (id == data->messageObId || id == data->syncObId || id == data->remote_messageObId || - id == data->remote_syncObId) - { - return true; - } - - return false; + return (id == data->messageObId || id == data->syncObId); } bool NSProviderCompareIdCacheData(NSCacheType type, void * data, const char * id) diff --git a/service/notification/src/provider/NSProviderNotification.c b/service/notification/src/provider/NSProviderNotification.c index 300ef1d..eee46bc 100644 --- a/service/notification/src/provider/NSProviderNotification.c +++ b/service/notification/src/provider/NSProviderNotification.c @@ -147,9 +147,7 @@ NSResult NSSendNotification(NSMessage *msg) NSCacheSubData * subData = (NSCacheSubData *) it->data; NS_LOG_V(INFO_PRIVATE, "message subData->id = %s", subData->id); NS_LOG_V(DEBUG, "subData->messageId = %d", subData->messageObId); - NS_LOG_V(DEBUG, "subData->cloud_messageId = %d", subData->remote_messageObId); NS_LOG_V(DEBUG, "subData->syncId = %d", subData->syncObId); - NS_LOG_V(DEBUG, "subData->cloud_syncId = %d", subData->remote_syncObId); NS_LOG_V(DEBUG, "subData->isWhite = %d", subData->isWhite); if (subData->isWhite) @@ -170,25 +168,6 @@ NSResult NSSendNotification(NSMessage *msg) obArray[obCount++] = subData->messageObId; } } - -#if (defined WITH_CLOUD) - if (subData->remote_messageObId != 0) - { - if (msg->topic && (msg->topic)[0] != '\0') - { - NS_LOG_V(DEBUG, "this is topic message via remote server: %s", msg->topic); - if (NSProviderIsTopicSubScribed(consumerTopicList->head, subData->id, msg->topic)) - { - obArray[obCount++] = subData->remote_messageObId; - } - } - else - { - obArray[obCount++] = subData->remote_messageObId; - } - } -#endif - } it = it->next; } @@ -250,9 +229,7 @@ NSResult NSSendSync(NSSyncInfo *sync) NSCacheSubData * subData = (NSCacheSubData *) it->data; NS_LOG_V(INFO_PRIVATE, "sync subData->id = %s", subData->id); NS_LOG_V(DEBUG, "subData->messageId = %d", subData->messageObId); - NS_LOG_V(DEBUG, "subData->cloud_messageId = %d", subData->remote_messageObId); NS_LOG_V(DEBUG, "subData->syncId = %d", subData->syncObId); - NS_LOG_V(DEBUG, "subData->cloud_syncId = %d", subData->remote_syncObId); NS_LOG_V(DEBUG, "subData->isWhite = %d", subData->isWhite); if (subData->isWhite) @@ -261,13 +238,6 @@ NSResult NSSendSync(NSSyncInfo *sync) { obArray[obCount++] = subData->syncObId; } - -#if (defined WITH_CLOUD) - if (subData->remote_syncObId != 0) - { - obArray[obCount++] = subData->remote_syncObId; - } -#endif } it = it->next; } diff --git a/service/notification/src/provider/NSProviderSubscription.c b/service/notification/src/provider/NSProviderSubscription.c index 52ad96d..b1f561b 100644 --- a/service/notification/src/provider/NSProviderSubscription.c +++ b/service/notification/src/provider/NSProviderSubscription.c @@ -149,29 +149,13 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour NS_LOG_V(INFO_PRIVATE, "Consumer Address: %s", entityHandlerRequest->devAddr.addr); - subData->remote_messageObId = subData->messageObId = 0; - - bool iSRemoteServer = false; - -#if(defined WITH_CLOUD) - iSRemoteServer = NSIsRemoteServerAddress(entityHandlerRequest->devAddr.addr); - if (iSRemoteServer) - { - NS_LOG(DEBUG, "Requested by remote server"); - subData->remote_messageObId = entityHandlerRequest->obsInfo.obsId; - NS_LOG_V(DEBUG, "SubList message observation ID = [%d]", subData->remote_messageObId); - } -#endif + subData->messageObId = 0; - if (!iSRemoteServer) - { - NS_LOG(DEBUG, "Requested by local consumer"); - subData->messageObId = entityHandlerRequest->obsInfo.obsId; - NS_LOG_V(DEBUG, "SubList message observation ID = [%d]", subData->messageObId); - } + NS_LOG(DEBUG, "Requested by local consumer"); + subData->messageObId = entityHandlerRequest->obsInfo.obsId; + NS_LOG_V(DEBUG, "SubList message observation ID = [%d]", subData->messageObId); subData->isWhite = false; - subData->remote_syncObId = 0; subData->syncObId = 0; element->data = (void*) subData; @@ -210,29 +194,15 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour NS_LOG_V(INFO_PRIVATE, "Consumer Address: %s", entityHandlerRequest->devAddr.addr); - subData->remote_syncObId = subData->syncObId = 0; - bool isRemoteServer = false; + subData->syncObId = 0; -#if (defined WITH_CLOUD) - isRemoteServer = NSIsRemoteServerAddress(entityHandlerRequest->devAddr.addr); - if (isRemoteServer) - { - NS_LOG(DEBUG, "Requested by remote server"); - subData->remote_syncObId = entityHandlerRequest->obsInfo.obsId; - NS_LOG_V(DEBUG, "SubList sync observation ID = [%d]", subData->remote_syncObId); - } -#endif + NS_LOG(DEBUG, "Requested by local consumer"); + subData->syncObId = entityHandlerRequest->obsInfo.obsId; + NS_LOG_V(DEBUG, "SubList sync observation ID = [%d]", subData->syncObId); - if (!isRemoteServer) - { - NS_LOG(DEBUG, "Requested by local consumer"); - subData->syncObId = entityHandlerRequest->obsInfo.obsId; - NS_LOG_V(DEBUG, "SubList sync observation ID = [%d]", subData->syncObId); - } subData->isWhite = false; subData->messageObId = 0; - subData->remote_messageObId = 0; element->data = (void*) subData; element->next = NULL; diff --git a/service/notification/src/provider/NSProviderSystem.c b/service/notification/src/provider/NSProviderSystem.c index a140367..b47f445 100644 --- a/service/notification/src/provider/NSProviderSystem.c +++ b/service/notification/src/provider/NSProviderSystem.c @@ -19,11 +19,6 @@ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "NSProviderSystem.h" -#if (defined WITH_CLOUD) -#define MAX_SERVER_ADDRESS 32 -static char NSRemoteServerAddress[MAX_SERVER_ADDRESS] = {0,}; -#endif - #ifdef WITH_MQ static NSMQServerInfo * mqServerInfo = NULL; #endif @@ -48,33 +43,6 @@ NSConnectionState NSGetProviderConnectionState() return NSProviderConnectionState; } -#if (defined WITH_CLOUD) -void NSSetRemoteServerAddress(char *serverAddress) -{ - - OICStrcpy(NSRemoteServerAddress, MAX_SERVER_ADDRESS, serverAddress); -} - -void NSDeleteRemoteServerAddress(char *serverAddress) -{ - NS_LOG_V(INFO_PRIVATE, "Delete cloud address: %s", serverAddress); - - memset(NSRemoteServerAddress, 0, MAX_SERVER_ADDRESS); -} - -bool NSIsRemoteServerAddress(char *serverAddress) -{ - NS_LOG_V(INFO_PRIVATE, "Check server address: %s", serverAddress); - - if (serverAddress != NULL) - { - return strstr(NSRemoteServerAddress, serverAddress); - } - - return false; -} -#endif - void NSInitProviderInfo(const char * userInfo) { NS_LOG(DEBUG, "NSInitProviderInfo"); diff --git a/service/notification/src/provider/NSProviderSystem.h b/service/notification/src/provider/NSProviderSystem.h index aa14921..edf65a8 100644 --- a/service/notification/src/provider/NSProviderSystem.h +++ b/service/notification/src/provider/NSProviderSystem.h @@ -46,10 +46,4 @@ void NSSetMQServerInfo(const char * serverUri, OCDevAddr * devAddr); NSMQServerInfo * NSGetMQServerInfo(); #endif -#if (defined WITH_CLOUD) -void NSSetRemoteServerAddress(char *serverAddress); -void NSDeleteRemoteServerAddress(char *serverAddress); -bool NSIsRemoteServerAddress(char *serverAddress); -#endif - #endif /* _NS_PROVIDER_SYSTEM__H_ */ diff --git a/service/notification/src/provider/NSProviderTopic.c b/service/notification/src/provider/NSProviderTopic.c index 3057dda..4cf1a08 100644 --- a/service/notification/src/provider/NSProviderTopic.c +++ b/service/notification/src/provider/NSProviderTopic.c @@ -156,13 +156,6 @@ NSResult NSSendTopicUpdation() { obArray[obCount++] = subData->messageObId; } - -#if (defined WITH_CLOUD) - if (subData->remote_messageObId != 0) - { - obArray[obCount++] = subData->remote_messageObId; - } -#endif } it = it->next; -- 2.7.4