Commit 8113caa8 authored by jake's avatar jake Committed by Uze Choi

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: default avatarjake <jaehong2.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17959Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarJungYong KIM <jyong2.kim@samsung.com>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent d94741fc
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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");
......
......@@ -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_ */
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment