Stop the application registration thread before orphaned threads
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Dec 2018 16:09:32 +0000 (11:09 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Dec 2018 21:34:34 +0000 (16:34 -0500)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/register.c
src/bin/lttng-sessiond/register.h

index 5f7600c0c0b200f4608903e4c2bd1069f105ea82..a96dc51952eb6ef84f127c027499795cfefcda76 100644 (file)
@@ -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:
index b75db4ed9533f9c0e73025602b3729514d89d111..6776019c68d3cdef3cfd4439906363a56b345c39 100644 (file)
@@ -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;
 }
index 71bb4de1e502a1978338deb613aa13908be7f344..d9bd0515523b58094b480e8ff1a2831ae37d04c6 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdbool.h>
 #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 */
This page took 0.042034 seconds and 5 git commands to generate.