diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp index 479667209..c24ea6bca 100644 --- a/src/common/consumer/consumer-stream.cpp +++ b/src/common/consumer/consumer-stream.cpp @@ -669,6 +669,7 @@ struct lttng_consumer_stream *consumer_stream_create( goto error; } + stream->send_node = CDS_LIST_HEAD_INIT(stream->send_node); stream->chan = channel; stream->key = stream_key; stream->trace_chunk = trace_chunk; @@ -1060,6 +1061,8 @@ void consumer_stream_destroy(struct lttng_consumer_stream *stream, { LTTNG_ASSERT(stream); + cds_list_del_init(&stream->send_node); + /* Stream is in monitor mode. */ if (stream->monitor) { struct lttng_consumer_channel *free_chan = NULL; diff --git a/src/common/consumer/consumer.cpp b/src/common/consumer/consumer.cpp index 838990cce..6166df4ed 100644 --- a/src/common/consumer/consumer.cpp +++ b/src/common/consumer/consumer.cpp @@ -174,7 +174,6 @@ static void clean_channel_stream_list(struct lttng_consumer_channel *channel) /* Delete streams that might have been left in the stream list. */ cds_list_for_each_entry_safe(stream, stmp, &channel->streams.head, send_node) { - cds_list_del(&stream->send_node); /* * Once a stream is added to this list, the buffers were created so we * have a guarantee that this call will succeed. Setting the monitor diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h index 10885fc1f..4bcd779f9 100644 --- a/src/common/consumer/consumer.h +++ b/src/common/consumer/consumer.h @@ -423,6 +423,11 @@ struct lttng_consumer_stream { struct lttng_ht_node_u64 node_channel_id; /* HT node used in consumer_data.stream_list_ht */ struct lttng_ht_node_u64 node_session_id; + /* + * List used by channels to reference streams that are not yet globally + * visible. + */ + struct cds_list_head send_node; /* Pointer to associated channel. */ struct lttng_consumer_channel *chan; /* @@ -555,7 +560,6 @@ struct lttng_consumer_stream { char name[LTTNG_SYMBOL_NAME_LEN]; /* Internal state of libustctl. */ struct lttng_ust_ctl_consumer_stream *ustream; - struct cds_list_head send_node; /* On-disk circular buffer */ uint64_t tracefile_size_current; uint64_t tracefile_count_current; diff --git a/src/common/kernel-consumer/kernel-consumer.cpp b/src/common/kernel-consumer/kernel-consumer.cpp index 52266f9eb..42242ad12 100644 --- a/src/common/kernel-consumer/kernel-consumer.cpp +++ b/src/common/kernel-consumer/kernel-consumer.cpp @@ -435,7 +435,6 @@ static int lttng_kconsumer_snapshot_metadata( ret = 0; error_snapshot: metadata_stream->read_subbuffer_ops.unlock(metadata_stream); - cds_list_del(&metadata_stream->send_node); consumer_stream_destroy(metadata_stream, NULL); metadata_channel->metadata_stream = NULL; rcu_read_unlock(); diff --git a/src/common/ust-consumer/ust-consumer.cpp b/src/common/ust-consumer/ust-consumer.cpp index 42a097b95..1740bbe71 100644 --- a/src/common/ust-consumer/ust-consumer.cpp +++ b/src/common/ust-consumer/ust-consumer.cpp @@ -67,7 +67,7 @@ static void destroy_channel(struct lttng_consumer_channel *channel) health_code_update(); - cds_list_del(&stream->send_node); + cds_list_del_init(&stream->send_node); lttng_ust_ctl_destroy_stream(stream->ustream); lttng_trace_chunk_put(stream->trace_chunk); free(stream); @@ -203,7 +203,7 @@ static int send_stream_to_thread(struct lttng_consumer_stream *stream, * global. */ stream->globally_visible = 1; - cds_list_del(&stream->send_node); + cds_list_del_init(&stream->send_node); ret = lttng_pipe_write(stream_pipe, &stream, sizeof(stream)); if (ret < 0) { @@ -950,7 +950,6 @@ static int setup_metadata(struct lttng_consumer_local_data *ctx, uint64_t key) * will make sure to clean that list. */ consumer_stream_destroy(metadata->metadata_stream, NULL); - cds_list_del(&metadata->metadata_stream->send_node); metadata->metadata_stream = NULL; send_streams_error: error_no_stream: @@ -1034,7 +1033,6 @@ static int snapshot_metadata(struct lttng_consumer_channel *metadata_channel, * new metadata stream. */ consumer_stream_destroy(metadata_stream, NULL); - cds_list_del(&metadata_stream->send_node); metadata_channel->metadata_stream = NULL; error: