Fix: Do not null out lttng_consumer_stream channel on deletion
authorKienan Stewart <kstewart@efficios.com>
Thu, 11 Jul 2024 14:34:52 +0000 (10:34 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Aug 2024 21:05:51 +0000 (21:05 +0000)
Change-Id: Ic98a27e6704d2683d24b8645d345955cee8b038c
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer-metadata-cache.cpp
src/common/consumer/consumer-timer.cpp
src/common/consumer/consumer.cpp
src/common/ust-consumer/ust-consumer.cpp

index 5e84f2b96f277ca7b80c4144feda327b717c2f99..9daf48a8c4b1945546f586c155fe03648cb0260f 100644 (file)
@@ -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<consumer_metadata_cache>();
        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)) {
index e6376bf1214a2005059fcbc194642891b665af87..f79a8061b3412d444c4a781a8f350be2ac865592 100644 (file)
@@ -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,
index f1f29d4292c4411c28dc2b756c7e6a98bbb3b42c..a44d397d0b2b8118138c0b7b53cef9674b6becc9 100644 (file)
@@ -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
index bb3e7346a7871b9641b15b04bdedb90eb66d9b95..eca03b8203d91c45e4c83e1383fae5fa973f3442 100644 (file)
@@ -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));
This page took 0.03096 seconds and 4 git commands to generate.