OCSetRAInfo(&rainfo);
#endif
+#ifdef WITH_PROCESS_EVENT
+ processEvent = oc_event_new();
+ if (!processEvent)
+ {
+ OIC_LOG(INFO, TAG, "oc_event_new failed!");
+ exit (EXIT_FAILURE);
+ }
+#endif
+
OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
OIC_LOG(INFO, TAG, "Device Registration failed!");
exit (EXIT_FAILURE);
}
-#ifdef WITH_PROCESS_EVENT
- processEvent = oc_event_new();
- if (!processEvent)
- {
- OIC_LOG(INFO, TAG, "oc_event_new failed!");
- exit (EXIT_FAILURE);
- }
+#ifdef WITH_PROCESS_EVENT
OCRegisterProcessEvent(processEvent);
#endif
OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ if (OCStop() != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "OCStack process error");
+ }
+
#ifdef WITH_PROCESS_EVENT
if (processEvent)
{
}
#endif
- if (OCStop() != OC_STACK_OK)
- {
- OIC_LOG(ERROR, TAG, "OCStack process error");
- }
-
return 0;
}
if (m_cfg.mode == ModeType::Client)
{
+#ifdef WITH_PROCESS_EVENT
+ if (false == m_threadRun)
+ {
+ m_processEvent = oc_event_new();
+ if (!m_processEvent)
+ {
+ OIC_LOG(INFO, TAG, "oc_event_new failed!");
+ return OC_STACK_ERROR;
+ }
+ }
+#endif
OCTransportFlags serverFlags =
static_cast<OCTransportFlags>(m_cfg.serverConnectivity & CT_MASK_FLAGS);
OCTransportFlags clientFlags =
{
m_threadRun = true;
#ifdef WITH_PROCESS_EVENT
- m_processEvent = oc_event_new();
- if (!m_processEvent)
- {
- OIC_LOG(INFO, TAG, "oc_event_new failed!");
- return OC_STACK_ERROR;
- }
OCRegisterProcessEvent(m_processEvent);
#endif
m_listeningThread = std::thread(&InProcClientWrapper::listeningFunc, this);
#endif
m_listeningThread.join();
}
+ OCStackResult result = OCStop();
+
+ if (OC_STACK_OK != result)
+ {
+ throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, result);
+ }
#ifdef WITH_PROCESS_EVENT
if (m_processEvent)
m_processEvent = NULL;
}
#endif
- OCStackResult result = OCStop();
-
- if (OC_STACK_OK != result)
- {
- throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, result);
- }
}
return OC_STACK_OK;
}
OC_STACK_INVALID_PARAM);
}
+#ifdef WITH_PROCESS_EVENT
+ if (false == m_threadRun)
+ {
+ m_processEvent = oc_event_new();
+ if (!m_processEvent)
+ {
+ OIC_LOG(INFO, TAG, "oc_event_new failed!");
+ return OC_STACK_ERROR;
+ }
+ }
+#endif
+
OCTransportFlags serverFlags =
static_cast<OCTransportFlags>(m_cfg.serverConnectivity & CT_MASK_FLAGS);
OCTransportFlags clientFlags =
{
m_threadRun = true;
#ifdef WITH_PROCESS_EVENT
- m_processEvent = oc_event_new();
- if (!m_processEvent)
- {
- OIC_LOG(INFO, TAG, "oc_event_new failed!");
- return OC_STACK_ERROR;
- }
OCRegisterProcessEvent(m_processEvent);
#endif
m_processThread = std::thread(&InProcServerWrapper::processFunc, this);
m_processThread.join();
}
+ OCStackResult res = OCStop();
+
+ if (OC_STACK_OK != res)
+ {
+ throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, res);
+ }
+
#ifdef WITH_PROCESS_EVENT
if (m_processEvent)
{
}
#endif
- OCStackResult res = OCStop();
-
- if (OC_STACK_OK != res)
- {
- throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, res);
- }
-
return OC_STACK_OK;
}