From bd0fe14c364275c50c2c5a486391e289a3068489 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Tue, 16 Jul 2024 09:31:52 -0400 Subject: [PATCH] Fix: Do not null out lttng_consumer_stream channel on deletion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ic98a27e6704d2683d24b8645d345955cee8b038c Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- src/common/consumer/consumer-metadata-cache.c | 2 ++ src/common/consumer/consumer-timer.c | 5 +++++ src/common/consumer/consumer.c | 1 - src/common/ust-consumer/ust-consumer.c | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common/consumer/consumer-metadata-cache.c b/src/common/consumer/consumer-metadata-cache.c index acb6cfe39..88b8ecb09 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -169,6 +169,7 @@ int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel) int ret; assert(channel); + assert(!channel->is_deleted); channel->metadata_cache = zmalloc( sizeof(struct consumer_metadata_cache)); @@ -233,6 +234,7 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, struct lttng_consumer_stream *metadata_stream; assert(channel); + assert(!channel->is_deleted); assert(channel->metadata_cache); /* diff --git a/src/common/consumer/consumer-timer.c b/src/common/consumer/consumer-timer.c index ecd920717..d19215a50 100644 --- a/src/common/consumer/consumer-timer.c +++ b/src/common/consumer/consumer-timer.c @@ -85,6 +85,7 @@ static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, channel = si->si_value.sival_ptr; assert(channel); + assert(!channel->is_deleted); if (channel->switch_timer_error) { return; @@ -279,6 +280,7 @@ static void live_timer(struct lttng_consumer_local_data *ctx, channel = si->si_value.sival_ptr; assert(channel); + assert(!channel->is_deleted); if (channel->switch_timer_error) { goto error; @@ -372,6 +374,7 @@ int consumer_channel_timer_start(timer_t *timer_id, struct itimerspec its; assert(channel); + assert(!channel->is_deleted); assert(channel->key); if (timer_interval_us == 0) { @@ -435,6 +438,7 @@ void consumer_timer_switch_start(struct lttng_consumer_channel *channel, int ret; assert(channel); + assert(!channel->is_deleted); assert(channel->key); ret = consumer_channel_timer_start(&channel->switch_timer, channel, @@ -508,6 +512,7 @@ int consumer_timer_monitor_start(struct lttng_consumer_channel *channel, int ret; assert(channel); + assert(!channel->is_deleted); assert(channel->key); assert(!channel->monitor_timer_enabled); diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index c457f754d..bc51ebac0 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -2178,7 +2178,6 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, /* Go for channel deletion! */ free_channel = true; } - stream->chan = NULL; /* * Nullify the stream reference so it is not used after deletion. The diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 65543ddf2..85ddec6d4 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -97,6 +97,7 @@ static int add_channel(struct lttng_consumer_channel *channel, int ret = 0; assert(channel); + assert(!channel->is_deleted); assert(ctx); if (ctx->on_recv_channel != NULL) { @@ -132,6 +133,7 @@ static struct lttng_consumer_stream *allocate_stream(int cpu, int key, struct lttng_consumer_stream *stream = NULL; assert(channel); + assert(!channel->is_deleted); assert(ctx); stream = consumer_stream_create( @@ -254,6 +256,7 @@ static int create_ust_streams(struct lttng_consumer_channel *channel, pthread_mutex_t *current_stream_lock = NULL; assert(channel); + assert(!channel->is_deleted); assert(ctx); /* @@ -430,6 +433,7 @@ static int create_ust_channel(struct lttng_consumer_channel *channel, struct ustctl_consumer_channel *ust_channel; assert(channel); + assert(!channel->is_deleted); assert(attr); assert(ust_chanp); assert(channel->buffer_credentials.is_set); @@ -544,6 +548,7 @@ static int send_channel_to_sessiond_and_relayd(int sock, uint64_t net_seq_idx = -1ULL; assert(channel); + assert(!channel->is_deleted); assert(ctx); assert(sock >= 0); @@ -640,6 +645,7 @@ static int ask_channel(struct lttng_consumer_local_data *ctx, assert(ctx); assert(channel); + assert(!channel->is_deleted); assert(attr); /* @@ -698,6 +704,7 @@ static int send_streams_to_thread(struct lttng_consumer_channel *channel, struct lttng_consumer_stream *stream, *stmp; assert(channel); + assert(!channel->is_deleted); assert(ctx); /* Send streams to the corresponding thread. */ @@ -3250,6 +3257,7 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, int ret; assert(channel); + assert(!channel->is_deleted); assert(channel->metadata_cache); memset(&request, 0, sizeof(request)); -- 2.34.1