From 753873bfbbfd0d7adb26c96223999a901ae46fd5 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 16 May 2017 16:55:56 -0400 Subject: [PATCH] Fix: Send remove channel to notification thread only when necessary MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: missing "channel" in commit title. Keep the publishing state to the notification thread of the channel object. Issue remove command if the channel was previously published. Fixes #1103 Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/kernel-consumer.c | 3 +++ src/bin/lttng-sessiond/trace-kernel.c | 4 +++- src/bin/lttng-sessiond/trace-kernel.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 067652b81..0f59aa24f 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -168,6 +168,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, ret = -1; goto error; } + + channel->published_to_notification_thread = true; + error: free(pathname); return ret; diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 5769576cd..083add3f3 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -221,6 +221,7 @@ struct ltt_kernel_channel *trace_kernel_create_channel( lkc->stream_count = 0; lkc->event_count = 0; lkc->enabled = 1; + lkc->published_to_notification_thread = false; /* Init linked list */ CDS_INIT_LIST_HEAD(&lkc->events_list.head); CDS_INIT_LIST_HEAD(&lkc->stream_list.head); @@ -522,7 +523,8 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) /* Remove from channel list */ cds_list_del(&channel->list); - if (notification_thread_handle) { + if (notification_thread_handle + && channel->published_to_notification_thread) { status = notification_thread_command_remove_channel( notification_thread_handle, channel->fd, LTTNG_DOMAIN_KERNEL); diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 93870cbfd..5879ca281 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -64,6 +64,7 @@ struct ltt_kernel_channel { int enabled; unsigned int stream_count; unsigned int event_count; + bool published_to_notification_thread; struct cds_list_head ctx_list; struct lttng_channel *channel; struct ltt_kernel_event_list events_list; -- 2.34.1