Cleanup ust-app.c and make it more modular
[lttng-tools.git] / lttng-sessiond / main.c
index ea3853c1a6f19b5a0132e86f287e82b3d313073a..cc7885399c288a24cabf2c10dd9e431b6b0778de 100644 (file)
@@ -338,12 +338,6 @@ static void cleanup(void)
 
        DBG("Cleaning up");
 
-       /* <fun> */
-       MSG("%c[%d;%dm*** assert failed *** ==> %c[%dm%c[%d;%dm"
-               "Matthew, BEET driven development works!%c[%dm",
-               27, 1, 31, 27, 0, 27, 1, 33, 27, 0);
-       /* </fun> */
-
        if (is_root) {
                DBG("Removing %s directory", LTTNG_RUNDIR);
                ret = asprintf(&cmd, "rm -rf " LTTNG_RUNDIR);
@@ -388,6 +382,12 @@ static void cleanup(void)
 
        close(thread_quit_pipe[0]);
        close(thread_quit_pipe[1]);
+
+       /* <fun> */
+       MSG("%c[%d;%dm*** assert failed :-) *** ==> %c[%dm%c[%d;%dm"
+                       "Matthew, BEET driven development works!%c[%dm",
+                       27, 1, 31, 27, 0, 27, 1, 33, 27, 0);
+       /* </fun> */
 }
 
 /*
@@ -711,6 +711,21 @@ error:
        return ret;
 }
 
+/*
+ * For each tracing session, update newly registered apps.
+ */
+static void update_ust_app(int app_sock)
+{
+       struct ltt_session *sess, *stmp;
+
+       /* For all tracing session(s) */
+       cds_list_for_each_entry_safe(sess, stmp, &session_list_ptr->head, list) {
+               if (sess->ust_session) {
+                       ust_app_global_update(sess->ust_session, app_sock);
+               }
+       }
+}
+
 /*
  * This thread manage event coming from the kernel.
  *
@@ -1062,6 +1077,12 @@ static void *thread_manage_apps(void *data)
                                                DBG("Apps with sock %d added to poll set",
                                                                ust_cmd.sock);
                                        }
+
+                                       /*
+                                        * Add channel(s) and event(s) to newly registered apps
+                                        * from lttng global UST domain.
+                                        */
+                                       update_ust_app(ust_cmd.sock);
                                        break;
                                }
                        } else {
@@ -1699,6 +1720,7 @@ static int create_ust_session(struct ltt_session *session,
                /* No ustctl for the global UST domain */
                break;
        default:
+               ERR("Unknown UST domain on create session %d", domain->type);
                goto error;
        }
        session->ust_session = lus;
@@ -1963,7 +1985,8 @@ static int cmd_enable_channel(struct ltt_session *session,
                        goto error;
                }
 
-               ret = ust_app_add_channel(usess, uchan);
+               /* Add channel to all registered applications */
+               ret = ust_app_add_channel_all(usess, uchan);
                if (ret != LTTCOMM_OK) {
                        goto error;
                }
@@ -2223,11 +2246,15 @@ static int cmd_enable_event(struct ltt_session *session, int domain,
                        }
                }
 
-               ret = ust_app_add_event(usess, uchan, uevent);
+               ret = ust_app_add_event_all(usess, uchan, uevent);
                if (ret < 0) {
                        ret = LTTCOMM_UST_ENABLE_FAIL;
                        goto error;
                }
+
+               rcu_read_lock();
+               hashtable_add_unique(uchan->events, &uevent->node);
+               rcu_read_unlock();
                break;
        }
        case LTTNG_DOMAIN_UST_EXEC_NAME:
@@ -2410,7 +2437,10 @@ static int cmd_start_trace(struct ltt_session *session)
                kernel_wait_quiescent(kernel_tracer_fd);
        }
 
-       ret = ust_app_start_trace(usess);
+       /* Flag session that trace should start automatically */
+       usess->start_trace = 1;
+
+       ret = ust_app_start_trace_all(usess);
        if (ret < 0) {
                ret = LTTCOMM_UST_START_FAIL;
                goto error;
This page took 0.029044 seconds and 5 git commands to generate.