From: Kienan Stewart Date: Thu, 11 Jul 2024 14:34:52 +0000 (-0400) Subject: Fix: Do not null out lttng_consumer_stream channel on deletion X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=7134be82708c0150ee89b9aec24f7b2e8aa58203;p=lttng-tools.git Fix: Do not null out lttng_consumer_stream channel on deletion Change-Id: Ic98a27e6704d2683d24b8645d345955cee8b038c Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/consumer/consumer-metadata-cache.cpp b/src/common/consumer/consumer-metadata-cache.cpp index 5e84f2b96..9daf48a8c 100644 --- a/src/common/consumer/consumer-metadata-cache.cpp +++ b/src/common/consumer/consumer-metadata-cache.cpp @@ -128,6 +128,7 @@ int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel) int ret; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); channel->metadata_cache = zmalloc(); if (!channel->metadata_cache) { @@ -250,6 +251,7 @@ void consumer_wait_metadata_cache_flushed(struct lttng_consumer_channel *channel 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.cpp b/src/common/consumer/consumer-timer.cpp index e6376bf12..f79a8061b 100644 --- a/src/common/consumer/consumer-timer.cpp +++ b/src/common/consumer/consumer-timer.cpp @@ -82,6 +82,7 @@ static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, siginfo channel = (lttng_consumer_channel *) si->si_value.sival_ptr; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); if (channel->switch_timer_error) { return; @@ -273,6 +274,7 @@ static void live_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si) auto *channel = (lttng_consumer_channel *) si->si_value.sival_ptr; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); if (channel->switch_timer_error) { return; @@ -363,6 +365,7 @@ static int consumer_channel_timer_start(timer_t *timer_id, LTTNG_ASSERT(channel); LTTNG_ASSERT(channel->key); + LTTNG_ASSERT(!channel->is_deleted); if (timer_interval_us == 0) { /* No creation needed; not an error. */ @@ -425,6 +428,7 @@ void consumer_timer_switch_start(struct lttng_consumer_channel *channel, LTTNG_ASSERT(channel); LTTNG_ASSERT(channel->key); + LTTNG_ASSERT(!channel->is_deleted); ret = consumer_channel_timer_start(&channel->switch_timer, channel, @@ -461,6 +465,7 @@ void consumer_timer_live_start(struct lttng_consumer_channel *channel, LTTNG_ASSERT(channel); LTTNG_ASSERT(channel->key); + LTTNG_ASSERT(!channel->is_deleted); ret = consumer_channel_timer_start( &channel->live_timer, channel, live_timer_interval_us, LTTNG_CONSUMER_SIG_LIVE); @@ -498,6 +503,7 @@ int consumer_timer_monitor_start(struct lttng_consumer_channel *channel, LTTNG_ASSERT(channel); LTTNG_ASSERT(channel->key); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(!channel->monitor_timer_enabled); ret = consumer_channel_timer_start(&channel->monitor_timer, diff --git a/src/common/consumer/consumer.cpp b/src/common/consumer/consumer.cpp index f1f29d429..a44d397d0 100644 --- a/src/common/consumer/consumer.cpp +++ b/src/common/consumer/consumer.cpp @@ -2114,7 +2114,6 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, struct l /* Go for channel deletion! */ free_channel = true; } - stream->chan = nullptr; /* * Nullify the stream reference so it is not used after deletion. The diff --git a/src/common/ust-consumer/ust-consumer.cpp b/src/common/ust-consumer/ust-consumer.cpp index bb3e7346a..eca03b820 100644 --- a/src/common/ust-consumer/ust-consumer.cpp +++ b/src/common/ust-consumer/ust-consumer.cpp @@ -64,6 +64,7 @@ static int add_channel(struct lttng_consumer_channel *channel, int ret = 0; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(ctx); if (ctx->on_recv_channel != nullptr) { @@ -101,6 +102,7 @@ static struct lttng_consumer_stream *allocate_stream(int cpu, struct lttng_consumer_stream *stream = nullptr; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(ctx); stream = consumer_stream_create(channel, @@ -221,6 +223,7 @@ static int create_ust_streams(struct lttng_consumer_channel *channel, pthread_mutex_t *current_stream_lock = nullptr; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(ctx); /* @@ -358,6 +361,7 @@ static int create_ust_channel(struct lttng_consumer_channel *channel, struct lttng_ust_ctl_consumer_channel *ust_channel; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(attr); LTTNG_ASSERT(ust_chanp); LTTNG_ASSERT(channel->buffer_credentials.is_set); @@ -479,6 +483,7 @@ static int send_channel_to_sessiond_and_relayd(int sock, uint64_t net_seq_idx = -1ULL; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(ctx); LTTNG_ASSERT(sock >= 0); @@ -579,6 +584,7 @@ static int ask_channel(struct lttng_consumer_local_data *ctx, LTTNG_ASSERT(ctx); LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(attr); /* @@ -636,6 +642,7 @@ static int send_streams_to_thread(struct lttng_consumer_channel *channel, int ret = 0; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(ctx); /* Send streams to the corresponding thread. */ @@ -3230,6 +3237,7 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, int ret; LTTNG_ASSERT(channel); + LTTNG_ASSERT(!channel->is_deleted); LTTNG_ASSERT(channel->metadata_cache); memset(&request, 0, sizeof(request));