Fix: keep ust/kernel session items around for destroy notifier
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Aug 2019 19:28:34 +0000 (15:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 23 Aug 2019 22:30:17 +0000 (15:30 -0700)
Split the destruction and release operations for ust and kernel
inner-sessions as they may be accessed by session destruction
notifiers registered against their parent ltt_session.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/kernel.h
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-kernel.h
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/trace-ust.h

index 4fdc34bad23fb329edf97b893ca8d103c4982cd6..955fd3ac27e9de62fac25a1cdce367f001b4c4f5 100644 (file)
@@ -131,6 +131,7 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd)
 error:
        if (lks) {
                trace_kernel_destroy_session(lks);
+               trace_kernel_free_session(lks);
        }
        return ret;
 }
@@ -1156,7 +1157,7 @@ end_boot_id:
 }
 
 /*
- * Complete teardown of a kernel session.
+ * Teardown of a kernel session, keeping data required by destroy notifiers.
  */
 void kernel_destroy_session(struct ltt_kernel_session *ksess)
 {
@@ -1205,6 +1206,15 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess)
        lttng_trace_chunk_put(trace_chunk);
 }
 
+/* Teardown of data required by destroy notifiers. */
+void kernel_free_session(struct ltt_kernel_session *ksess)
+{
+       if (ksess == NULL) {
+               return;
+       }
+       trace_kernel_free_session(ksess);
+}
+
 /*
  * Destroy a kernel channel object. It does not do anything on the tracer side.
  */
index 978e4cb93517485a5463c316f9b53ba6f8e73a15..c822e8d768f7acc524ad14c71d53ca689fcccb94 100644 (file)
@@ -58,6 +58,7 @@ int kernel_validate_version(int tracer_fd,
                struct lttng_kernel_tracer_version *kernel_tracer_version,
                struct lttng_kernel_tracer_abi_version *kernel_tracer_abi_version);
 void kernel_destroy_session(struct ltt_kernel_session *ksess);
+void kernel_free_session(struct ltt_kernel_session *ksess);
 void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
 enum lttng_error_code kernel_snapshot_record(
                struct ltt_kernel_session *ksess,
index 6e187f2ff51df9c17fb162f0096e7e6a92d7a372..514b11e9919da0c2814aa99096c4bcd99862d892 100644 (file)
@@ -802,11 +802,10 @@ void session_release(struct urcu_ref *ref)
        usess = session->ust_session;
        ksess = session->kernel_session;
 
-        /* Clean kernel session teardown */
+        /* Clean kernel session teardown, keeping data for destroy notifier. */
        kernel_destroy_session(ksess);
-       session->kernel_session = NULL;
 
-       /* UST session teardown */
+       /* UST session teardown, keeping data for destroy notifier. */
        if (usess) {
                /* Close any relayd session */
                consumer_output_send_destroy_relayd(usess->consumer);
@@ -817,9 +816,8 @@ void session_release(struct urcu_ref *ref)
                        ERR("Error in ust_app_destroy_trace_all");
                }
 
-               /* Clean up the rest. */
+               /* Clean up the rest, keeping destroy notifier data. */
                trace_ust_destroy_session(usess);
-               session->ust_session = NULL;
        }
 
        /*
@@ -844,6 +842,13 @@ void session_release(struct urcu_ref *ref)
                del_session_ht(session);
        }
        session_notify_destruction(session);
+
+       kernel_free_session(ksess);
+       session->kernel_session = NULL;
+       if (usess) {
+               trace_ust_free_session(usess);
+               session->ust_session = NULL;
+       }
        lttng_dynamic_array_reset(&session->destroy_notifiers);
        free(session->last_archived_chunk_name);
        free(session);
index a8aa01b269e9bc05bd4aeb28148899f38a154a06..36af00b2d09a4ba3d5b97e0b74eed509fedd64c2 100644 (file)
@@ -710,7 +710,11 @@ void trace_kernel_destroy_session(struct ltt_kernel_session *session)
        cds_list_for_each_entry_safe(channel, ctmp, &session->channel_list.head, list) {
                trace_kernel_destroy_channel(channel);
        }
+}
 
+/* Free elements needed by destroy notifiers. */
+void trace_kernel_free_session(struct ltt_kernel_session *session)
+{
        /* Wipe consumer output object */
        consumer_output_put(session->consumer);
 
index 00c76a8d321d0102a3f2257c9e1fdb1161cf1873..3b211740ab5c632cbae9db9ddb50c3eafa7e98b7 100644 (file)
@@ -164,5 +164,6 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
 void trace_kernel_destroy_event(struct ltt_kernel_event *event);
 void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
 void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
+void trace_kernel_free_session(struct ltt_kernel_session *session);
 
 #endif /* _LTT_TRACE_KERNEL_H */
index b1bae1794ab70560d7e4e74c4520793659de4ac9..569599af28c5e7fb6658855f99276d9ef92ea736 100644 (file)
@@ -1161,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.
  */
@@ -1197,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);
 }
index 58339802671b11e3fdb0dfd07bd0587eb3edc8d3..9316fa8174df1db069fec8cc2d91f61444f182ec 100644 (file)
@@ -217,6 +217,7 @@ void trace_ust_destroy_session(struct ltt_ust_session *session);
 void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
 void trace_ust_destroy_event(struct ltt_ust_event *event);
 void trace_ust_destroy_context(struct ltt_ust_context *ctx);
+void trace_ust_free_session(struct ltt_ust_session *session);
 
 int trace_ust_track_pid(struct ltt_ust_session *session, int pid);
 int trace_ust_untrack_pid(struct ltt_ust_session *session, int pid);
@@ -279,6 +280,12 @@ static inline
 void trace_ust_destroy_event(struct ltt_ust_event *event)
 {
 }
+
+static inline
+void trace_ust_free_session(struct ltt_ust_session *session)
+{
+}
+
 static inline
 struct ltt_ust_context *trace_ust_create_context(
                struct lttng_event_context *ctx)
This page took 0.031712 seconds and 4 git commands to generate.