static GHashTable *_ctsvc_handle_table = NULL;
-static int _ctsvc_client_handle_get_key(unsigned int id, char *key, int key_len)
+static int _client_handle_get_key(unsigned int id, char *key, int key_len)
{
- int ret;
- int len;
-
- ret = gethostname(key, key_len);
- RETVM_IF(0 != ret, CONTACTS_ERROR_SYSTEM, "gethostname() Failed(%d)", errno);
-
- len = strlen(key);
- snprintf(key+len, key_len-len, ":%u", id);
+ RETV_IF(NULL == key, CONTACTS_ERROR_INVALID_PARAMETER);
+ snprintf(key, key_len, "%d:%u", getuid(), id);
+ DBG("key[%s]", key);
return CONTACTS_ERROR_NONE;
}
char key[CTSVC_STR_SHORT_LEN] = {0};
contacts_h contact = NULL;
- RETVM_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA, "_ctsvc_handle_table is NULL");
+ RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA);
+ RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
- ret = _ctsvc_client_handle_get_key(id, key, sizeof(key));
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+ ret = _client_handle_get_key(id, key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
contact = g_hash_table_lookup(_ctsvc_handle_table, key);
ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
if (NULL == contact) {
- CTS_ERR("g_hash_table_lookup() return NULL");
+ /* LCOV_EXCL_START */
+ ERR("g_hash_table_lookup() Fail. key[%s]", key);
return CONTACTS_ERROR_NO_DATA;
+ /* LCOV_EXCL_STOP */
}
*p_contact = contact;
char key[CTSVC_STR_SHORT_LEN] = {0};
contacts_h contact = NULL;
- RETVM_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA, "_ctsvc_handle_table is NULL");
+ RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA);
+ RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
- ret = _ctsvc_client_handle_get_key(ctsvc_client_get_tid(), key, sizeof(key));
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+ ret = _client_handle_get_key(ctsvc_client_get_tid(), key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
contact = g_hash_table_lookup(_ctsvc_handle_table, key);
ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
if (NULL == contact) {
- ret = _ctsvc_client_handle_get_key(ctsvc_client_get_pid(), key, sizeof(key));
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+ ret = _client_handle_get_key(ctsvc_client_get_pid(), key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
contact = g_hash_table_lookup(_ctsvc_handle_table, key);
ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
-
- RETVM_IF(NULL == contact, CONTACTS_ERROR_NO_DATA, "g_hash_table_lookup() return NULL");
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_NO_DATA, "g_hash_table_lookup(%s) Fail", key);
}
*p_contact = contact;
return CONTACTS_ERROR_NONE;
char handle_key[CTSVC_STR_SHORT_LEN] = {0};
contacts_h contact = NULL;
- RETVM_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER, "p_contact is NULL");
+ RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
*p_contact = NULL;
- ret = _ctsvc_client_handle_get_key(id, handle_key, sizeof(handle_key));
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+ ret = _client_handle_get_key(id, handle_key, sizeof(handle_key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
ret = ctsvc_handle_create(&contact);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_handle_create() Fail(%d)", ret);
_ctsvc_handle_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
g_hash_table_insert(_ctsvc_handle_table, strdup(handle_key), contact);
+ INFO("handle insert key[%s]", handle_key);
ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
*p_contact = contact;
{
int ret;
char key[CTSVC_STR_SHORT_LEN] = {0};
- RETVM_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NONE, "_ctsvc_handle_table is NULL");
- ret = _ctsvc_client_handle_get_key(id, key, sizeof(key));
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+ RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NONE);
+
+ ret = _client_handle_get_key(id, key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
if (false == g_hash_table_remove(_ctsvc_handle_table, key))
- CTS_ERR("g_hash_table_remove() Fail. key:%s", key);
+ 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);