g_dp_client->notify = open(notify_fifo, O_RDONLY, 0600);
if (g_dp_client->notify < 0) {
TRACE_ERROR("[CRITICAL] failed to ESTABILISH IPC %s", notify_fifo);
- CLIENT_MUTEX_LOCK(&g_function_mutex);
g_dp_event_thread_id = 0;
+ CLIENT_MUTEX_LOCK(&g_function_mutex);
__clear_interface();
CLIENT_MUTEX_UNLOCK(&g_function_mutex);
return 0;
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
while (g_dp_client != NULL && g_dp_client->notify >= 0) {
- CLIENT_MUTEX_LOCK(&g_function_mutex);
if (g_dp_event_thread_id <= 0 ||
pthread_self() != g_dp_event_thread_id) {
TRACE_ERROR("competitive threads self:%lu global:%lu",
pthread_self(), g_dp_event_thread_id);
// another thread may work. just terminate
- CLIENT_MUTEX_UNLOCK(&g_function_mutex);
break;
}
- CLIENT_MUTEX_UNLOCK(&g_function_mutex);
// blocking fifo.
dp_ipc_event_fmt eventinfo;
(eventinfo.id <= 0 &&
eventinfo.errorcode == DP_ERROR_CLIENT_DOWN)) {
TRACE_INFO("expelled by provider");
- CLIENT_MUTEX_LOCK(&g_function_mutex);
g_dp_event_thread_id = 0;
+ CLIENT_MUTEX_LOCK(&g_function_mutex);
__clear_interface();
CLIENT_MUTEX_UNLOCK(&g_function_mutex);
return 0;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
} // while
- CLIENT_MUTEX_LOCK(&g_function_mutex);
g_dp_event_thread_id = 0; // set 0 to not call pthread_cancel
- CLIENT_MUTEX_UNLOCK(&g_function_mutex);
TRACE_DEBUG("thread end by itself");
return 0;
}