From 15dc512ac8cf2f59c8779f442f116a23975c950c Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 25 Feb 2014 12:21:32 -0500 Subject: [PATCH] Fix: kernel channel destroy on consumer if sent An enable-channel immediately followed by a destroy session triggered an assert on the consumer followed by the shutdown of the consumer thread for the kernel. This fix make sure we don't ask the consumer to destroy a channel if not previously sent to it and handle not found channel on destroy. Fixes #643 Signed-off-by: David Goulet --- src/bin/lttng-sessiond/kernel.c | 8 ++++---- src/common/kernel-consumer/kernel-consumer.c | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index b6b24a5a2..faf35cc7f 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -759,11 +759,11 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess) DBG("Tearing down kernel session"); /* - * Destroy channels on the consumer if in no output mode because the - * streams are in *no* monitor mode so we have to send a command to clean - * them up or else they leaked. + * Destroy channels on the consumer if at least one FD has been sent and we + * are in no output mode because the streams are in *no* monitor mode so we + * have to send a command to clean them up or else they leaked. */ - if (!ksess->output_traces) { + if (!ksess->output_traces && ksess->consumer_fds_sent) { int ret; struct consumer_socket *socket; struct lttng_ht_iter iter; diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index ab4f604d7..d15329ffa 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -918,6 +918,11 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); + /* Stop right now if no channel was found. */ + if (!channel) { + goto end_nosignal; + } + /* * This command should ONLY be issued for channel with streams set in * no monitor mode. -- 2.34.1