From 4b1b22ebcfc332db79982297e16a3dd56e0ae4de Mon Sep 17 00:00:00 2001 From: Jaekyun Lee Date: Thu, 18 Apr 2013 15:10:46 +0900 Subject: [PATCH] Avoid Thread race condition Change-Id: I5c4be24751c968b012474d3dce3433d3f30f5454 --- src/clientlib/net_nfc_client_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } } -- 2.7.4