[lttng-tools,v2] Fix: Send remove channel to notification thread only when necessary
diff mbox

Message ID 20170516205556.6322-1-jonathan.rajotte-julien@efficios.com
State Accepted, archived
Delegated to: Jérémie Galarneau
Headers show

Commit Message

Jonathan Rajotte May 16, 2017, 8:55 p.m. UTC
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 <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(-)

Comments

Jérémie Galarneau June 13, 2017, 3:45 p.m. UTC | #1
Merged in master and stable-2.10. Thanks!

Jérémie

On 16 May 2017 at 16:55, Jonathan Rajotte
<jonathan.rajotte-julien at efficios.com> wrote:
> 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 <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
>

Patch
diff mbox

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;