Fix: keep ust/kernel session items around for destroy notifier
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.c
index 45dbec74e174feac9a7aba9932666b87f18e5628..569599af28c5e7fb6658855f99276d9ef92ea736 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <common/common.h>
 #include <common/defaults.h>
+#include <common/trace-chunk.h>
 
 #include "buffer-registry.h"
 #include "trace-ust.h"
@@ -827,13 +828,14 @@ int trace_ust_pid_tracker_lookup(struct ltt_ust_session *session, int pid)
 int trace_ust_track_pid(struct ltt_ust_session *session, int pid)
 {
        int retval = LTTNG_OK;
+       bool should_update_apps = false;
 
        if (pid == -1) {
                /* Track all pids: destroy tracker if exists. */
                if (session->pid_tracker.ht) {
                        fini_pid_tracker(&session->pid_tracker);
                        /* Ensure all apps have session. */
-                       ust_app_global_update_all(session);
+                       should_update_apps = true;
                }
        } else {
                int ret;
@@ -852,7 +854,7 @@ int trace_ust_track_pid(struct ltt_ust_session *session, int pid)
                                goto end;
                        }
                        /* Remove all apps from session except pid. */
-                       ust_app_global_update_all(session);
+                       should_update_apps = true;
                } else {
                        struct ust_app *app;
 
@@ -864,10 +866,13 @@ int trace_ust_track_pid(struct ltt_ust_session *session, int pid)
                        /* Add session to application */
                        app = ust_app_find_by_pid(pid);
                        if (app) {
-                               ust_app_global_update(session, app);
+                               should_update_apps = true;
                        }
                }
        }
+       if (should_update_apps && session->active) {
+               ust_app_global_update_all(session);
+       }
 end:
        return retval;
 }
@@ -1156,7 +1161,8 @@ static void destroy_domain_global(struct ltt_ust_domain_global *dom)
 }
 
 /*
- * Cleanup ust session structure
+ * Cleanup ust session structure, keeping data required by
+ * destroy notifier.
  *
  * Should *NOT* be called with RCU read-side lock held.
  */
@@ -1192,9 +1198,13 @@ void trace_ust_destroy_session(struct ltt_ust_session *session)
                buffer_reg_uid_destroy(reg, session->consumer);
        }
 
-       consumer_output_put(session->consumer);
-
        fini_pid_tracker(&session->pid_tracker);
+       lttng_trace_chunk_put(session->current_trace_chunk);
+}
 
+/* Free elements needed by destroy notifiers. */
+void trace_ust_free_session(struct ltt_ust_session *session)
+{
+       consumer_output_put(session->consumer);
        free(session);
 }
This page took 0.024661 seconds and 4 git commands to generate.