Add internal kernel channel destroy function
authorDavid Goulet <dgoulet@efficios.com>
Mon, 14 Jan 2013 19:41:38 +0000 (14:41 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 14 Jan 2013 19:51:22 +0000 (14:51 -0500)
The internal representation of a kernel channel in the session daemon
now has a session pointer that points to the associated session. This is
needed so when we destroy a channel, we can update the channel count of
the session if available.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/kernel.h
src/bin/lttng-sessiond/trace-kernel.h

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++;
        /* 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);
 
 
        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);
 }
 
        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--;
+       }
+}
index 86ae00371bdc4790d1bd82fa15ad112e15468322..4813c931dadda4a86f2781cd1014d22a859e8851 100644 (file)
@@ -52,6 +52,7 @@ void kernel_wait_quiescent(int fd);
 int kernel_calibrate(int fd, struct lttng_kernel_calibrate *calibrate);
 int kernel_validate_version(int tracer_fd);
 void kernel_destroy_session(struct ltt_kernel_session *ksess);
 int kernel_calibrate(int fd, struct lttng_kernel_calibrate *calibrate);
 int kernel_validate_version(int tracer_fd);
 void kernel_destroy_session(struct ltt_kernel_session *ksess);
+void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
 
 int init_kernel_workarounds(void);
 
 
 int init_kernel_workarounds(void);
 
index 27baa6d3954bfecc1f03145909e73c5ee72dc480..8bd1ffe321b1075460ba53ef5bf3de79b69d92f9 100644 (file)
@@ -65,6 +65,8 @@ struct ltt_kernel_channel {
        struct ltt_kernel_event_list events_list;
        struct ltt_kernel_stream_list stream_list;
        struct cds_list_head list;
        struct ltt_kernel_event_list events_list;
        struct ltt_kernel_stream_list stream_list;
        struct cds_list_head list;
+       /* Session pointer which has a reference to this object. */
+       struct ltt_kernel_session *session;
 };
 
 /* Metadata */
 };
 
 /* Metadata */
This page took 0.028252 seconds and 4 git commands to generate.