Fix a crash issue when the application is terminating.
authoreh1112.kim <eh1112.kim@samsung.com>
Wed, 12 Jun 2013 02:32:55 +0000 (11:32 +0900)
committereh1112.kim <eh1112.kim@samsung.com>
Wed, 12 Jun 2013 02:32:55 +0000 (11:32 +0900)
Change-Id: Ie8f34958f3244970911dd6f92280d30ea0956e26
Signed-off-by: eh1112.kim <eh1112.kim@samsung.com>
src/FNet_NetConnectionManagerImpl.cpp [changed mode: 0644->0755]
src/FNet_NetIpcProxy.cpp [changed mode: 0644->0755]
src/FNet_NetIpcProxy.h [changed mode: 0644->0755]
src/FNet_NetUtility.cpp [changed mode: 0644->0755]
src/FNet_SystemNetConnection.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b977d12..6403767
@@ -452,13 +452,16 @@ void
 _NetConnectionManagerImpl::InitSingleton(void)
 {
     result r = E_SUCCESS;
-    static _NetConnectionManagerImpl instance;
 
-    r = instance.Construct();
+    unique_ptr<_NetConnectionManagerImpl> pInstance(new (std::nothrow) _NetConnectionManagerImpl());
+       SysTryReturnVoidResult(NID_NET, pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pInstance->Construct();
        SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        ClearLastResult();
-       __pInstance = &instance;
+
+       __pInstance = pInstance.release();
 }
 
 result
old mode 100644 (file)
new mode 100755 (executable)
index 6cd15ae..db6068d
@@ -24,6 +24,7 @@
 
 
 #include <pthread.h>
+#include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FBaseString.h>
 #include <FNetNetTypes.h>
@@ -90,12 +91,16 @@ void
 _NetIpcProxy::InitSingleton(void)
 {
     result r = E_SUCCESS;
-    static _NetIpcProxy instance;
 
-    r = instance.Construct();
+    unique_ptr<_NetIpcProxy> pInstance(new (std::nothrow) _NetIpcProxy());
+       SysTryReturnVoidResult(NID_NET, pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pInstance->Construct();
        SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       __pInstance = &instance;
+       ClearLastResult();
+
+       __pInstance = pInstance.release();
 }
 
 result
old mode 100644 (file)
new mode 100755 (executable)
index b91bcc5..202e735
@@ -74,6 +74,8 @@ private:
        std::unique_ptr<Tizen::Io::_IpcClient> __pIpcClient;
        static _NetIpcProxy* __pInstance;
 
+       friend class std::default_delete<_NetIpcProxy>;
+
 }; // _NetIpcProxy
 
 }}
old mode 100644 (file)
new mode 100755 (executable)
index f4b5a2b..22bd3c4
@@ -22,6 +22,7 @@
  */
 
 #include <pthread.h>
+#include <unique_ptr.h>
 #include <FBaseResult.h>
 #include <FBaseObject.h>
 #include <FBaseString.h>
@@ -29,6 +30,7 @@
 #include <FBaseSysLog.h>
 #include "FNet_NetUtility.h"
 
+using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 
@@ -67,13 +69,16 @@ void
 _NetUtility::InitLock(void)
 {
     result r = E_SUCCESS;
-    static Mutex lock;
 
-    r = lock.Create(L"NetLock");
+    unique_ptr<Mutex> pLock(new (std::nothrow) Mutex());
+       SysTryReturnVoidResult(NID_NET, pLock != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pLock->Create(L"NetLock");
        SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       __pLock = &lock;
+       ClearLastResult();
 
+       __pLock = pLock.release();
 }
 
 }} // Tizen::Net
old mode 100644 (file)
new mode 100755 (executable)
index 35ec2e5..55297dc
@@ -23,6 +23,7 @@
  */
 
 #include <pthread.h>
+#include <unique_ptr.h>
 #include <net_connection.h>
 #include <FNetNetConnectionInfo.h>
 #include <FBaseRtMutexGuard.h>