From 68df1111a67d6df0c952b5057e424b96c0f088cc Mon Sep 17 00:00:00 2001 From: KIM JungYong Date: Mon, 10 Oct 2016 16:11:46 +0900 Subject: [PATCH] [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/13005 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../examples/linux/notificationserviceconsumer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; -- 2.7.4