From: Mathieu Desnoyers Date: Thu, 3 Mar 2011 23:21:52 +0000 (-0500) Subject: Add pthread cleanup to listener (to cleanup mutex) X-Git-Tag: v0.12~14 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e625e9191bcb16522072aa34301cc517392f85ba;p=ust.git Add pthread cleanup to listener (to cleanup mutex) Signed-off-by: Mathieu Desnoyers --- diff --git a/libust/tracectl.c b/libust/tracectl.c index 3b60975..b058cb3 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -543,6 +543,11 @@ unlock_traces: return retval; } +static void release_listener_mutex(void *ptr) +{ + pthread_mutex_unlock(&listener_thread_data_mutex); +} + static void listener_cleanup(void *ptr) { pthread_mutex_lock(&listen_sock_mutex); @@ -1096,6 +1101,7 @@ void *listener_main(void *p) for (i = 0; i < nfds; i++) { pthread_mutex_lock(&listener_thread_data_mutex); + pthread_cleanup_push(release_listener_mutex, NULL); epoll_sock = (struct ustcomm_sock *)events[i].data.ptr; if (epoll_sock == listen_sock) { addr_size = sizeof(struct sockaddr); @@ -1124,7 +1130,7 @@ void *listener_main(void *p) epoll_sock->fd); } } - pthread_mutex_unlock(&listener_thread_data_mutex); + pthread_cleanup_pop(1); /* release listener mutex */ } }