From: David Goulet Date: Mon, 14 Jan 2013 19:41:38 +0000 (-0500) Subject: Add internal kernel channel destroy function X-Git-Tag: v2.2.0-rc1~116 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fb5f35b688fa31b21b25f9a6a831df3e5aa243ed;p=lttng-tools.git Add internal kernel channel destroy function 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 --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 3471fd940..b417cb077 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -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--; + } +} diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h index 86ae00371..4813c931d 100644 --- a/src/bin/lttng-sessiond/kernel.h +++ b/src/bin/lttng-sessiond/kernel.h @@ -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); +void kernel_destroy_channel(struct ltt_kernel_channel *kchan); int init_kernel_workarounds(void); diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 27baa6d39..8bd1ffe32 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -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; + /* Session pointer which has a reference to this object. */ + struct ltt_kernel_session *session; }; /* Metadata */