From: Gwangbok Kim Date: Mon, 15 Apr 2013 05:09:30 +0000 (+0900) Subject: fix code for N_SE-34155 X-Git-Tag: 2.1b_release~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b716dcd3d3fc8ce96fc84cba786f146e96d8d443;p=framework%2Fosp%2Fsocial.git fix code for N_SE-34155 Change-Id: I84659bc8ab00648730ce85bc00ae37ee194bc733 Signed-off-by: Gwangbok Kim --- diff --git a/src/FScl_ContactDbConnector.cpp b/src/FScl_ContactDbConnector.cpp index e5978a9..db664ef 100644 --- a/src/FScl_ContactDbConnector.cpp +++ b/src/FScl_ContactDbConnector.cpp @@ -30,8 +30,7 @@ namespace Tizen { namespace Social { -__thread bool isConnected = false; -pthread_key_t tlsKey = 0; +bool _ContactDbConnector::__isConnected = false; _ContactDbConnector* _ContactDbConnector::__pInstance = null; _ContactDbConnector::_ContactDbConnector(void) @@ -42,19 +41,6 @@ _ContactDbConnector::~_ContactDbConnector(void) { } -void -_ContactDbConnector::OnThreadExit(void *pValue) -{ - _ContactDbConnector* pInstance = static_cast<_ContactDbConnector*>(pValue); - - if (pInstance != null) - { - pInstance->Disconnect(); - } - - pthread_setspecific(tlsKey, NULL); -} - result _ContactDbConnector::Connect(void) { @@ -71,8 +57,6 @@ _ContactDbConnector::Connect(void) SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_IPC_NOT_AVALIABLE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Contact server is not available. Elapsed time : %lld", GetErrorMessage(E_SYSTEM), endTicks - startTicks); SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); - pthread_setspecific(tlsKey, this); - return E_SUCCESS; } @@ -89,7 +73,7 @@ _ContactDbConnector::Disconnect(void) result _ContactDbConnector::EnsureDbConnection(void) { - if (!isConnected) + if (!__isConnected) { _ContactDbConnector* pInstance = GetInstance(); SysTryReturn(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); @@ -97,7 +81,7 @@ _ContactDbConnector::EnsureDbConnection(void) result r = pInstance->Connect(); SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); - isConnected = true; + __isConnected = true; } return E_SUCCESS; @@ -111,8 +95,6 @@ _ContactDbConnector::InitContactDbConnector(void) __pInstance = pInstance.release(); - pthread_key_create(&tlsKey, OnThreadExit); - std::atexit(DestroyContactDbConnector); } diff --git a/src/FScl_ContactDbConnector.h b/src/FScl_ContactDbConnector.h index afeb5b6..cc28c53 100644 --- a/src/FScl_ContactDbConnector.h +++ b/src/FScl_ContactDbConnector.h @@ -35,8 +35,6 @@ public: static _ContactDbConnector* GetInstance(void); - static void OnThreadExit(void *pValue); - result Connect(void); result Disconnect(void); @@ -53,6 +51,7 @@ private: private: static _ContactDbConnector* __pInstance; + static bool __isConnected; friend class std::default_delete< _ContactDbConnector >; };