Stop the application registration thread before orphaned threads
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 1fbfb1b0549383cd77e5334aad25338320cb6d56..a96dc51952eb6ef84f127c027499795cfefcda76 100644 (file)
@@ -69,7 +69,7 @@
 #include "fd-limit.h"
 #include "health-sessiond.h"
 #include "testpoint.h"
-#include "ust-thread.h"
+#include "notify-apps.h"
 #include "agent-thread.h"
 #include "save.h"
 #include "notification-thread.h"
@@ -1353,6 +1353,8 @@ int main(int argc, char **argv)
        /* Queue of rotation jobs populated by the sessiond-timer. */
        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();
 
@@ -1702,7 +1704,9 @@ int main(int argc, char **argv)
        }
 
        /* Create notification thread. */
-       if (!launch_notification_thread(notification_thread_handle)) {
+       notification_thread = launch_notification_thread(
+                       notification_thread_handle);
+       if (!notification_thread) {
                retval = -1;
                goto exit_notification;
        }
@@ -1744,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;
        }
@@ -1812,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:
@@ -1837,6 +1847,11 @@ exit_init_data:
        rcu_thread_online();
        sessiond_cleanup();
 
+       if (notification_thread) {
+               lttng_thread_shutdown(notification_thread);
+               lttng_thread_put(notification_thread);
+       }
+
        /*
         * Ensure all prior call_rcu are done. call_rcu callbacks may push
         * hash tables to the ht_cleanup thread. Therefore, we ensure that
This page took 0.025319 seconds and 4 git commands to generate.