Add internal kernel channel destroy function
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index 3471fd940dc7f390f44d863fdd5447181360334a..b417cb07759c4f30795b9240508b31e2148ffd77 100644 (file)
@@ -148,6 +148,7 @@ int kernel_create_channel(struct ltt_kernel_session *session,
        /* Add channel to session */
        cds_list_add(&lkc->list, &session->channel_list.head);
        session->channel_count++;
+       lkc->session = session;
 
        DBG("Kernel channel %s created (fd: %d)", lkc->channel->name, lkc->fd);
 
@@ -708,3 +709,33 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess)
 
        trace_kernel_destroy_session(ksess);
 }
+
+/*
+ * Destroy a kernel channel object. It does not do anything on the tracer side.
+ */
+void kernel_destroy_channel(struct ltt_kernel_channel *kchan)
+{
+       struct ltt_kernel_session *ksess = NULL;
+
+       assert(kchan);
+       assert(kchan->channel);
+
+       DBG3("Kernel destroy channel %s", kchan->channel->name);
+
+       /* Update channel count of associated session. */
+       if (kchan->session) {
+               /* Keep pointer reference so we can update it after the destroy. */
+               ksess = kchan->session;
+       }
+
+       trace_kernel_destroy_channel(kchan);
+
+       /*
+        * At this point the kernel channel is not visible anymore. This is safe
+        * since in order to work on a visible kernel session, the tracing session
+        * lock (ltt_session.lock) MUST be acquired.
+        */
+       if (ksess) {
+               ksess->channel_count--;
+       }
+}
This page took 0.033118 seconds and 4 git commands to generate.