From 6de5c854570cca2aad7264c08df9ae8f8e72fa49 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 a5943fd33..7607e21fd 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -129,6 +129,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)); @@ -252,6 +253,7 @@ void consumer_wait_metadata_cache_flushed(struct lttng_consumer_channel *channel uint64_t offset, bool invoked_by_timer) { assert(channel); + assert(!channel->is_deleted); assert(channel->metadata_cache); if (consumer_metadata_cache_is_flushed(channel, offset, invoked_by_timer)) { diff --git a/src/common/consumer/consumer-timer.c b/src/common/consumer/consumer-timer.c index b6bde28b3..785047d7c 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; @@ -283,6 +284,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; @@ -376,6 +378,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) { @@ -439,6 +442,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, @@ -513,6 +517,7 @@ int consumer_timer_monitor_start(struct lttng_consumer_channel *channel, assert(channel); assert(channel->key); + assert(!channel->is_deleted); assert(!channel->monitor_timer_enabled); ret = consumer_channel_timer_start(&channel->monitor_timer, channel, diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index ff88c7f1e..0e7970f39 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -2168,7 +2168,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 af605052b..7ffbaaa8e 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -101,6 +101,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) { @@ -136,6 +137,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( @@ -258,6 +260,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); /* @@ -393,6 +396,7 @@ static int create_ust_channel(struct lttng_consumer_channel *channel, struct lttng_ust_ctl_consumer_channel *ust_channel; assert(channel); + assert(!channel->is_deleted); assert(attr); assert(ust_chanp); assert(channel->buffer_credentials.is_set); @@ -511,6 +515,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); @@ -607,6 +612,7 @@ static int ask_channel(struct lttng_consumer_local_data *ctx, assert(ctx); assert(channel); + assert(!channel->is_deleted); assert(attr); /* @@ -665,6 +671,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. */ @@ -3322,6 +3329,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