X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=3709092198e5a9d1fcf6781134ba7e645ce3e202;hb=a32bd7757cc9f642b3977897819982ed1eb3be80;hp=990db9e2690eff92ec683b8dd1df1aef65542ab0;hpb=4c95e622041958250db73b497097ed93f7715e20;p=lttng-tools.git diff --git a/src/common/consumer.c b/src/common/consumer.c index 990db9e26..370909219 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -102,6 +102,7 @@ static void notify_channel_pipe(struct lttng_consumer_local_data *ctx, msg.action = action; msg.chan = chan; + msg.key = key; do { ret = write(ctx->consumer_channel_pipe[1], &msg, sizeof(msg)); } while (ret < 0 && errno == EINTR); @@ -906,7 +907,7 @@ int consumer_add_channel(struct lttng_consumer_channel *channel, /* Channel already exist. Ignore the insertion */ ERR("Consumer add channel key %" PRIu64 " already exists!", channel->key); - ret = -1; + ret = LTTNG_ERR_KERN_CHAN_EXIST; goto end; } @@ -1959,6 +1960,13 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, } end: + /* + * Nullify the stream reference so it is not used after deletion. The + * consumer data lock MUST be acquired before being able to check for a + * NULL pointer value. + */ + stream->chan->metadata_stream = NULL; + pthread_mutex_unlock(&stream->lock); pthread_mutex_unlock(&consumer_data.lock); @@ -2011,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 @@ -2968,7 +2973,7 @@ end: } } if (client_socket >= 0) { - ret = close(sock); + ret = close(client_socket); if (ret < 0) { PERROR("close client_socket sessiond poll"); }