Fix for crash in InProcClientWrapper destructor.
authorjihwanseo <jihwan.seo@samsung.com>
Fri, 2 Dec 2016 11:40:41 +0000 (20:40 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Mon, 12 Dec 2016 15:22:34 +0000 (15:22 +0000)
InProcClientWrapper::stop() throws an exception when stack
is already stopped. Not catching this exception would terminate
application.

Change-Id: I50bb6befb716049da275c16a4fdbf96437c2ad03
Signed-off-by: Harry <h.marappa@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15169
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/src/InProcClientWrapper.cpp
resource/src/InProcServerWrapper.cpp

index 9c63705..6a4b15c 100644 (file)
@@ -45,7 +45,14 @@ namespace OC
 
     InProcClientWrapper::~InProcClientWrapper()
     {
-        stop();
+        try
+        {
+            stop();
+        }
+        catch (InitializeException &e)
+        {
+            oclog() << "Exception in stop"<< e.what() << std::flush;
+        }
     }
 
     OCStackResult InProcClientWrapper::start()
@@ -90,9 +97,9 @@ namespace OC
             OCStackResult result = OCStop();
 
             if (OC_STACK_OK != result)
-           {
+            {
                throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, result);
-           }
+            }
         }
         return OC_STACK_OK;
     }
index cd762e3..43a926b 100644 (file)
@@ -318,7 +318,12 @@ namespace OC
 
         OCStackResult res = OCStop();
 
-        return res;
+        if (OC_STACK_OK != res)
+        {
+           throw InitializeException(OC::InitException::STACK_TERMINATE_ERROR, res);
+        }
+
+        return OC_STACK_OK;
     }
 
     void InProcServerWrapper::processFunc()
@@ -656,6 +661,13 @@ namespace OC
 
     InProcServerWrapper::~InProcServerWrapper()
     {
-        stop();
+        try
+        {
+            stop();
+        }
+        catch (InitializeException &e)
+        {
+            oclog() << "Exception in stop"<< e.what() << std::flush;
+        }
     }
 }