From bd9addf713e7dc8fc47499f62312966a3a5f4d46 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 6 Dec 2018 11:09:32 -0500 Subject: [PATCH] Stop the application registration thread before orphaned threads MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The application registration thread receives new connections from applications, provides them to the dispatch thread. The dispatch thread, in turn, forwards the command and notification sockets of applications (liblttng-ust) to the application management and application notification threads. Not shutting down the application registration thread is problematic since application connections will be accepted but not associated to an "ust_app" structure as the following threads are no longer present. The remaining threads can then be safely torn down as part of the orphaned threads. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/main.c | 9 ++++++++- src/bin/lttng-sessiond/register.c | 7 +++---- src/bin/lttng-sessiond/register.h | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 5f7600c0c..a96dc5195 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -1354,6 +1354,7 @@ int main(int argc, char **argv) struct rotation_thread_timer_queue *rotation_timer_queue = NULL; struct lttng_thread *client_thread = NULL; struct lttng_thread *notification_thread = NULL; + struct lttng_thread *register_apps_thread = NULL; init_kernel_workarounds(); @@ -1747,7 +1748,9 @@ int main(int argc, char **argv) } /* Create thread to manage application registration. */ - if (!launch_application_registration_thread(&ust_cmd_queue)) { + register_apps_thread = launch_application_registration_thread( + &ust_cmd_queue); + if (!register_apps_thread) { retval = -1; goto exit_reg_apps; } @@ -1815,6 +1818,10 @@ exit_kernel: exit_agent_reg: exit_apps_notify: exit_apps: + if (register_apps_thread) { + lttng_thread_shutdown(register_apps_thread); + lttng_thread_put(register_apps_thread); + } exit_reg_apps: exit_dispatch: exit_client: diff --git a/src/bin/lttng-sessiond/register.c b/src/bin/lttng-sessiond/register.c index b75db4ed9..6776019c6 100644 --- a/src/bin/lttng-sessiond/register.c +++ b/src/bin/lttng-sessiond/register.c @@ -361,7 +361,7 @@ static bool shutdown_application_registration_thread(void *data) return notify_thread_pipe(write_fd) == 1; } -bool launch_application_registration_thread( +struct lttng_thread *launch_application_registration_thread( struct ust_cmd_queue *cmd_queue) { struct lttng_pipe *quit_pipe; @@ -388,9 +388,8 @@ bool launch_application_registration_thread( if (!thread) { goto error; } - lttng_thread_put(thread); - return true; + return thread; error: cleanup_application_registration_thread(notifiers); - return false; + return NULL; } diff --git a/src/bin/lttng-sessiond/register.h b/src/bin/lttng-sessiond/register.h index 71bb4de1e..d9bd05155 100644 --- a/src/bin/lttng-sessiond/register.h +++ b/src/bin/lttng-sessiond/register.h @@ -23,6 +23,7 @@ #include #include "lttng-sessiond.h" -bool launch_application_registration_thread(struct ust_cmd_queue *cmd_queue); +struct lttng_thread *launch_application_registration_thread( + struct ust_cmd_queue *cmd_queue); #endif /* SESSIOND_APPLICATION_REGISTRATION_THREAD_H */ -- 2.34.1