From 6be1a3866f735b0fea61044bd3b6079f5be6aaae Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 15 May 2017 15:14:07 -0400 Subject: [PATCH] Fix: pthread_join on thread start error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/main.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 5a6741f2d..9b6f70cd0 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -5618,6 +5618,7 @@ int main(int argc, char **argv) struct lttng_pipe *ust32_channel_monitor_pipe = NULL, *ust64_channel_monitor_pipe = NULL, *kernel_channel_monitor_pipe = NULL; + bool notification_thread_running = false; init_kernel_workarounds(); @@ -6129,6 +6130,7 @@ int main(int argc, char **argv) stop_threads(); goto exit_notification; } + notification_thread_running = true; /* Create thread to manage the client socket */ ret = pthread_create(&client_thread, default_pthread_attr(), @@ -6332,15 +6334,17 @@ exit_init_data: * of the active session and channels at the moment of the teardown. */ if (notification_thread_handle) { - notification_thread_command_quit(notification_thread_handle); - notification_thread_handle_destroy(notification_thread_handle); - - ret = pthread_join(notification_thread, &status); - if (ret) { - errno = ret; - PERROR("pthread_join notification thread"); - retval = -1; + if (notification_thread_running) { + notification_thread_command_quit( + notification_thread_handle); + ret = pthread_join(notification_thread, &status); + if (ret) { + errno = ret; + PERROR("pthread_join notification thread"); + retval = -1; + } } + notification_thread_handle_destroy(notification_thread_handle); } rcu_thread_offline(); -- 2.34.1