From a0c83db984f8c20897666eef226b43fce81d0e13 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 29 May 2013 12:19:57 -0400 Subject: [PATCH] Fix: remove one too many metadata refcount increment The refcount increment is removed from the add metadata stream function so for both kernel and UST, the increment is done once the stream is allocated and the channel reference is set. Signed-off-by: David Goulet --- src/common/consumer.c | 3 --- src/common/kernel-consumer/kernel-consumer.c | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/common/consumer.c b/src/common/consumer.c index a856f030e..370909219 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -2019,9 +2019,6 @@ static int add_metadata_stream(struct lttng_consumer_stream *stream, uatomic_inc(&relayd->refcount); } - /* Update channel refcount once added without error(s). */ - uatomic_inc(&stream->chan->refcount); - /* * When nb_init_stream_left reaches 0, we don't need to trigger any action * in terms of destroying the associated channel, because the action that diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index f47c49877..c0d56171c 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -255,11 +255,11 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, new_stream->chan = channel; new_stream->wait_fd = fd; - /* Metadata chan refcount is increment in add_metadata_stream */ - if (new_stream->chan->type != CONSUMER_CHANNEL_TYPE_METADATA) { - /* Update channel refcount */ - uatomic_inc(&new_stream->chan->refcount); - } + /* + * We've just assigned the channel to the stream so increment the + * refcount right now. + */ + uatomic_inc(&new_stream->chan->refcount); /* * The buffer flush is done on the session daemon side for the kernel -- 2.34.1