Fix: wait for the completion of implicit session rotations
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index c45280d11583f0d8f1f44b125546b24b7d5e3232..ac7f7c910317d45158ac75991fa55cea17af7610 100644 (file)
@@ -1023,7 +1023,11 @@ static int set_permissions(char *rundir)
        int ret;
        gid_t gid;
 
-       gid = utils_get_group_id(config.tracing_group_name.value);
+       ret = utils_get_group_id(config.tracing_group_name.value, true, &gid);
+       if (ret) {
+               /* Default to root group. */
+               gid = 0;
+       }
 
        /* Set lttng run dir */
        ret = chown(rundir, 0, gid);
@@ -1134,7 +1138,16 @@ static int set_consumer_sockets(struct consumer_data *consumer_data)
                goto error;
        }
        if (is_root) {
-               ret = chown(path, 0, utils_get_group_id(config.tracing_group_name.value));
+               gid_t gid;
+
+               ret = utils_get_group_id(config.tracing_group_name.value, true,
+                               &gid);
+               if (ret) {
+                       /* Default to root group. */
+                       gid = 0;
+               }
+
+               ret = chown(path, 0, gid);
                if (ret < 0) {
                        ERR("Unable to set group on %s", path);
                        PERROR("chown");
@@ -1322,8 +1335,8 @@ static void destroy_all_sessions_and_wait(void)
                        goto unlock_session;
                }
                (void) cmd_stop_trace(session);
-               (void) cmd_destroy_session(session,
-                               notification_thread_handle);
+               (void) cmd_destroy_session(session, notification_thread_handle,
+                               NULL);
        unlock_session:
                session_unlock(session);
                session_put(session);
@@ -1336,6 +1349,34 @@ static void destroy_all_sessions_and_wait(void)
        DBG("Destruction of all sessions completed");
 }
 
+static int run_as_worker_post_fork_cleanup(void *data)
+{
+       struct sessiond_config *sessiond_config = data;
+
+       sessiond_config_fini(sessiond_config);
+       return 0;
+}
+
+static int launch_run_as_worker(const char *procname)
+{
+       /*
+        * Clean-up before forking the run-as worker. Any dynamically
+        * allocated memory of which the worker is not aware will
+        * be leaked as the process forks a run-as worker (and performs
+        * no exec*()). The same would apply to any opened fd.
+        */
+       return run_as_create_worker(procname, run_as_worker_post_fork_cleanup,
+                       &config);
+}
+
+static void sessiond_uuid_log(void)
+{
+       char uuid_str[UUID_STR_LEN];
+
+       lttng_uuid_to_str(sessiond_uuid, uuid_str);
+       DBG("Starting lttng-sessiond {%s}", uuid_str);
+}
+
 /*
  * main
  */
@@ -1432,6 +1473,7 @@ int main(int argc, char **argv)
        set_clock_plugin_env();
 
        sessiond_config_log(&config);
+       sessiond_uuid_log();
 
        if (create_lttng_rundir()) {
                retval = -1;
@@ -1469,7 +1511,7 @@ int main(int argc, char **argv)
                }
        }
 
-       if (run_as_create_worker(argv[0]) < 0) {
+       if (launch_run_as_worker(argv[0]) < 0) {
                goto exit_create_run_as_worker_cleanup;
        }
 
This page took 0.024039 seconds and 4 git commands to generate.