From: KIM JungYong Date: Mon, 10 Oct 2016 07:11:46 +0000 (+0900) Subject: [IOT-1430] bug fix for seg fault on start consumer. X-Git-Tag: 1.2.0+RC4~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c4e5959f01180e0873b0337224f46100bfa98a0;p=platform%2Fupstream%2Fiotivity.git [IOT-1430] bug fix for seg fault on start consumer. With this patch, segmentation fault is resolved on the starting consumer service. Change-Id: I929ec45d34a401ea7e6e503d6c686471656f39cf Signed-off-by: KIM JungYong Reviewed-on: https://gerrit.iotivity.org/gerrit/13007 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/notification/cpp-wrapper/examples/linux/notificationserviceconsumer.cpp b/service/notification/cpp-wrapper/examples/linux/notificationserviceconsumer.cpp index f567b4a..e005bcf 100755 --- a/service/notification/cpp-wrapper/examples/linux/notificationserviceconsumer.cpp +++ b/service/notification/cpp-wrapper/examples/linux/notificationserviceconsumer.cpp @@ -35,6 +35,12 @@ bool isExit = false; std::string REMOTE_SERVER_ADDRESS; std::string mainProvider; +FILE* server_fopen(const char *path, const char *mode) +{ + (void)path; + return fopen("oic_ns_provider_db.dat", mode); +} + void onNotificationPostedCb(OIC::Service::NSMessage *notification) { std::cout << "id : " << notification->getMessageId() << std::endl; @@ -128,7 +134,12 @@ int main(void) pthread_t OCThread = NULL; std::cout << "start Iotivity" << std::endl; - if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK) + + // open oic_db + static OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink}; + OCRegisterPersistentStorageHandler(&ps); + + if (OCInit1(OC_CLIENT_SERVER, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK) { std::cout << "OCInit fail" << std::endl; return 0;