From: David Goulet Date: Tue, 4 Dec 2012 23:17:55 +0000 (-0500) Subject: Fix: don't steal key when adding a metadata stream X-Git-Tag: v2.1.0~80 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7608208897f23f1419759e786175247a39703a79;p=lttng-tools.git Fix: don't steal key when adding a metadata stream This was causing a stream corruption of the node key if the stream->key of the metadata was matching a stream wait_fd making the stream not findable and asserting when getting out of the metadata poll wait. Now we lookup the stream before adding it to make sure it's unique and don't try to steal the key anymore since wait_fd is unique to the consumer. Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/common/consumer.c b/src/common/consumer.c index f69f0081a..260779ae6 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1874,6 +1874,8 @@ static int consumer_add_metadata_stream(struct lttng_consumer_stream *stream, { int ret = 0; struct consumer_relayd_sock_pair *relayd; + struct lttng_ht_iter iter; + struct lttng_ht_node_ulong *node; assert(stream); assert(ht); @@ -1889,6 +1891,15 @@ static int consumer_add_metadata_stream(struct lttng_consumer_stream *stream, */ rcu_read_lock(); + + /* + * Lookup the stream just to make sure it does not exist in our internal + * state. This should NEVER happen. + */ + lttng_ht_lookup(ht, (void *)((unsigned long) stream->wait_fd), &iter); + node = lttng_ht_iter_get_node_ulong(&iter); + assert(!node); + /* Find relayd and, if one is found, increment refcount. */ relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd != NULL) { @@ -1909,9 +1920,6 @@ static int consumer_add_metadata_stream(struct lttng_consumer_stream *stream, uatomic_dec(&stream->chan->nb_init_streams); } - /* Steal stream identifier to avoid having streams with the same key */ - consumer_steal_stream_key(stream->key, ht); - lttng_ht_add_unique_ulong(ht, &stream->node); /*