From: Jaekyun Lee Date: Thu, 18 Apr 2013 06:10:46 +0000 (+0900) Subject: Avoid Thread race condition X-Git-Tag: submit/tizen/20130703.180622~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b1b22ebcfc332db79982297e16a3dd56e0ae4de;p=platform%2Fcore%2Fconnectivity%2Fnfc-manager-neard.git Avoid Thread race condition Change-Id: I5c4be24751c968b012474d3dce3433d3f30f5454 --- diff --git a/src/clientlib/net_nfc_client_ipc.c b/src/clientlib/net_nfc_client_ipc.c index 2ba7f3b..79be676 100755 --- a/src/clientlib/net_nfc_client_ipc.c +++ b/src/clientlib/net_nfc_client_ipc.c @@ -441,7 +441,6 @@ static void *net_nfc_client_ipc_thread(void *data) msg = net_nfc_client_read_response_msg(&result); - pthread_mutex_lock(&cb_lock); if (msg != NULL && msg->detail_message != NULL) { /* TODO : need to remove */ @@ -461,6 +460,7 @@ static void *net_nfc_client_ipc_thread(void *data) } else { + pthread_mutex_lock(&cb_lock); #ifdef USE_GLIB_MAIN_LOOP net_nfc_client_call_dispatcher_in_g_main_loop(client_cb, msg); #elif USE_ECORE_MAIN_LOOP @@ -468,6 +468,7 @@ static void *net_nfc_client_ipc_thread(void *data) #else net_nfc_client_call_dispatcher_in_current_context(client_cb, msg); #endif + pthread_mutex_unlock(&cb_lock); } } else @@ -482,7 +483,6 @@ static void *net_nfc_client_ipc_thread(void *data) } DEBUG_ERR_MSG("cannot read response msg"); } - pthread_mutex_unlock(&cb_lock); } }