[CONPRO-1442] Fix crash in cpp wrapper. 38/208338/1
authorJaehyun Cho <jaehyun3.cho@samsung.com>
Mon, 20 May 2019 05:38:04 +0000 (14:38 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 24 Jun 2019 00:48:47 +0000 (09:48 +0900)
When application is run with Both mode, in InProcClientWrapper start
logic for making procession thread is not executed. But, when stop
application, thread join processing and event free logic is executed
regardless mode. So I moved that logic into mode check statement. This
can make that logic is executed only mode is client.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/b5c0bd60cef0c305dfb07239cbfbd3529a39afec
(cherry picked from b5c0bd60cef0c305dfb07239cbfbd3529a39afec)

Change-Id: I713f0019051f4970d6122e458186795fd070112e
Signed-off-by: Jaehyun Cho <jaehyun3.cho@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/src/InProcClientWrapper.cpp

index 0dfc3b6..132d082 100755 (executable)
@@ -98,30 +98,29 @@ namespace OC
     {
         OIC_LOG(INFO, TAG, "stop ocplatform");
 
-        if (m_threadRun && m_listeningThread.joinable())
+        // only stop if we are the ones who actually called 'start'.  We are counting
+        // on the server to do the stop.
+        if (m_cfg.mode == ModeType::Client)
         {
-            m_threadRun = false;
-#ifdef WITH_PROCESS_EVENT
-            if (m_processEvent)
+            if (m_threadRun && m_listeningThread.joinable())
             {
-                oc_event_signal(m_processEvent);
-            }
+                m_threadRun = false;
+#ifdef WITH_PROCESS_EVENT
+                if (m_processEvent)
+                {
+                    oc_event_signal(m_processEvent);
+                }
 #endif
-            m_listeningThread.join();
-        }
+                m_listeningThread.join();
+            }
 
 #ifdef WITH_PROCESS_EVENT
-        if (m_processEvent)
-        {
-            oc_event_free(m_processEvent);
-            m_processEvent = NULL;
-        }
+            if (m_processEvent)
+            {
+                oc_event_free(m_processEvent);
+                m_processEvent = NULL;
+            }
 #endif
-
-        // only stop if we are the ones who actually called 'start'.  We are counting
-        // on the server to do the stop.
-        if (m_cfg.mode == ModeType::Client)
-        {
             OCStackResult result = OCStop();
 
             if (OC_STACK_OK != result)