[lttng-dev] [PATCH lttng-tools] Fix: Send remove to notification thread only when necessary

Jonathan Rajotte jonathan.rajotte-julien at efficios.com
Tue May 16 20:24:25 UTC 2017


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 <jonathan.rajotte-julien at efficios.com>
---
 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 a65e1493..79b6cd72 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 5769576c..083add3f 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 2092469a..c311329b 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.11.0



More information about the lttng-dev mailing list