From: jyong2.kim Date: Tue, 28 Apr 2015 11:41:47 +0000 (+0900) Subject: Fix for API return type of Notification Manager issues about return value of APIs. X-Git-Tag: 1.2.0+RC1~1777 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6221e7803db5853c155a570cf6a7652f98091e1;p=platform%2Fupstream%2Fiotivity.git Fix for API return type of Notification Manager issues about return value of APIs. 1. fix return value of APIs. 2. handle exception about memory. [IOT-501] [IOT-502] Change-Id: I77e54efe9e44572a8f7bd83849dc6215ff6daa79 Signed-off-by: jyong2.kim Reviewed-on: https://gerrit.iotivity.org/gerrit/854 Reviewed-by: Uze Choi Tested-by: Uze Choi --- diff --git a/service/notification-manager/NotificationManager/src/hosting.c b/service/notification-manager/NotificationManager/src/hosting.c index 772a6ae..66b1b36 100755 --- a/service/notification-manager/NotificationManager/src/hosting.c +++ b/service/notification-manager/NotificationManager/src/hosting.c @@ -351,17 +351,32 @@ OCStackResult registerResourceAsCoordinatable(OCResourceHandle *handle, */ OCStackResult OICStartCoordinate() { - s_mirrorResourceList = createMirrorResourceList(); - s_requestHandleList = createRequestHandleList(); + OCStackResult ret = OC_STACK_ERROR; + if (OCInit((char *) NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK) + { + OC_LOG(ERROR, HOSTING_TAG, PCF("OCStack init ERROR")); + } + else + { + s_mirrorResourceList = createMirrorResourceList(); + s_requestHandleList = createRequestHandleList(); + ret = requestPresence(OC_MULTICAST_PREFIX); + } - return requestPresence(OC_MULTICAST_PREFIX); + return ret; } OCStackResult OICStopCoordinate() { OCStackResult result = OC_STACK_ERROR; + if (OCStop() == OC_STACK_OK) + { + OC_LOG_V(DEBUG, HOSTING_TAG, "OCStack Stop OK"); + } + result = destroyMirrorResourceList(s_mirrorResourceList); + s_mirrorResourceList = NULL; if(result != OC_STACK_OK) { return OC_STACK_ERROR; diff --git a/service/notification-manager/SampleApp/linux/notificationManager/main.c b/service/notification-manager/SampleApp/linux/notificationManager/main.c index 9340681..830db3a 100755 --- a/service/notification-manager/SampleApp/linux/notificationManager/main.c +++ b/service/notification-manager/SampleApp/linux/notificationManager/main.c @@ -41,7 +41,11 @@ int main() return 0; } - OICStartCoordinate(); + if (OICStartCoordinate() != OC_STACK_OK) + { + printf("OIC coordinate start fail\n"); + return 0; + } signal(SIGINT, handleSigInt); while (!g_quitFlag) @@ -56,7 +60,14 @@ int main() sleep(2); } - OICStopCoordinate(); + if (OICStopCoordinate() != OC_STACK_OK) + { + printf("OIC coordinate stop error\n"); + } + else + { + printf("OIC coordinate stop success\n"); + } printf("Exiting occlient main loop...\n");