ctsvc_client_handle_remove in CTS_MUTEX_CONNECTION during disconnect_on_thread 52/47852/1
authorGukhwan Cho <gh78.cho@samsung.com>
Wed, 26 Aug 2015 06:35:23 +0000 (15:35 +0900)
committerGukhwan Cho <gh78.cho@samsung.com>
Wed, 9 Sep 2015 10:54:29 +0000 (19:54 +0900)
Change-Id: Ic734d8b057a4d5ce07ad0cec240400082648a5ef
Signed-off-by: Gukhwan Cho <gh78.cho@samsung.com>
client/ctsvc_client_handle.c
client/ctsvc_client_service.c
client/ctsvc_client_service_helper.c
common/ctsvc_internal.h

index 84f10e4..4f93390 100644 (file)
@@ -57,8 +57,7 @@ int ctsvc_client_handle_get_p_with_id(unsigned int id, contacts_h *p_contact)
        contact = g_hash_table_lookup(_ctsvc_handle_table, key);
        ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
 
-       if (NULL == contact)
-       {
+       if (NULL == contact) {
                CTS_ERR("g_hash_table_lookup() return NULL");
                return CONTACTS_ERROR_NO_DATA;
        }
@@ -132,7 +131,9 @@ int ctsvc_client_handle_remove(unsigned int id, contacts_h contact)
        RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
 
        ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
-       g_hash_table_remove(_ctsvc_handle_table, key);
+       if (false == g_hash_table_remove(_ctsvc_handle_table, key))
+               CTS_ERR("g_hash_table_remove() Fail. key:%s", key);
+
        if (0 == g_hash_table_size(_ctsvc_handle_table)) {
                g_hash_table_destroy(_ctsvc_handle_table);
                _ctsvc_handle_table = NULL;
index 56a968f..b4440f7 100644 (file)
@@ -155,11 +155,6 @@ API int contacts_disconnect_on_thread(void)
        if (CONTACTS_ERROR_INVALID_PARAMETER == ret)
                ret = CONTACTS_ERROR_IPC;
 
-       if (0 == ((ctsvc_base_s *)contact)->connection_count) {
-               ret = ctsvc_client_handle_remove(id, contact);
-               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_handle_remove() Fail(%d)", ret);
-       }
-
        return ret;
 }
 
index 41ce751..83d5d42 100644 (file)
@@ -172,6 +172,7 @@ int ctsvc_client_disconnect(contacts_h contact)
        _ctsvc_connection--;
 
        if (0 == base->connection_count) {
+               CTS_INFO("connection_count is 0. remove handle");
                ret = ctsvc_client_handle_remove(ctsvc_client_get_pid(), contact);
                WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_handle_remove() Fail(%d)", ret);
        }
@@ -266,6 +267,11 @@ int ctsvc_client_disconnect_on_thread(contacts_h contact)
 
        _ctsvc_connection_on_thread--;
 
+       if (0 == base->connection_count) {
+               CTS_INFO("connection_count is 0. remove handle");
+               ret = ctsvc_client_handle_remove(ctsvc_client_get_tid(), contact);
+               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_handle_remove() Fail(%d)", ret);
+       }
        ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
 
        return CONTACTS_ERROR_NONE;
index 74604f0..3e61dd6 100644 (file)
@@ -77,7 +77,7 @@
        #define CTS_DBG(fmt, arg...)
        #define CTS_WARN(fmt, arg...)
        #define CTS_ERR(fmt, arg...) ERR(fmt, ##arg)
-       #define CTS_INFO(fmt, arg...)
+       #define CTS_INFO(fmt, arg...) INFO(fmt, ##arg)
        #define CTS_VERBOSE(fmt, arg...)
 
        #define G_DISABLE_ASSERT