From: Jérémie Galarneau Date: Thu, 6 Dec 2018 16:09:32 +0000 (-0500) Subject: Stop the application registration thread before orphaned threads X-Git-Tag: v2.11.0-rc2~122 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=143745a6d56824ceb630548e96f95ea54361c5ff;p=lttng-tools.git Stop the application registration thread before orphaned threads 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 --- 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 */