Fix: Document the locking assumptions of ctf_trace_find_by_path()
[lttng-tools.git] / src / bin / lttng-relayd / ctf-trace.c
index 6fe77a5b4438f5833e9eaa9bfeb3c092aaacf964..02a8b2bf16e6b553ccd6d4059c88634aa42bd49d 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <assert.h>
 
 #include <common/common.h>
@@ -38,6 +39,14 @@ static void rcu_destroy_ctf_trace(struct rcu_head *head)
        free(trace);
 }
 
+static void rcu_destroy_stream(struct rcu_head *head)
+{
+       struct relay_stream *stream =
+               caa_container_of(head, struct relay_stream, rcu_node);
+
+       stream_destroy(stream);
+}
+
 /*
  * Destroy a ctf trace and all stream contained in it.
  *
@@ -57,7 +66,7 @@ void ctf_trace_destroy(struct ctf_trace *obj)
        cds_list_for_each_entry_safe(stream, tmp_stream, &obj->stream_list,
                        trace_list) {
                stream_delete(relay_streams_ht, stream);
-               stream_destroy(stream);
+               call_rcu(&stream->rcu_node, rcu_destroy_stream);
        }
 
        call_rcu(&obj->node.head, rcu_destroy_ctf_trace);
@@ -75,6 +84,7 @@ void ctf_trace_try_destroy(struct relay_session *session,
         */
        if (uatomic_read(&session->viewer_refcount) == 0 &&
                        uatomic_read(&ctf_trace->refcount) == 0) {
+               ctf_trace_delete(session->ctf_traces_ht, ctf_trace);
                ctf_trace_destroy(ctf_trace);
        }
 }
@@ -107,6 +117,8 @@ error:
 
 /*
  * Return a ctf_trace object if found by id in the given hash table else NULL.
+ *
+ * Must be called with rcu_read_lock() taken.
  */
 struct ctf_trace *ctf_trace_find_by_path(struct lttng_ht *ht,
                char *path_name)
This page took 0.023984 seconds and 4 git commands to generate.