X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=3709092198e5a9d1fcf6781134ba7e645ce3e202;hb=a0c83db984f8c20897666eef226b43fce81d0e13;hp=b5fe9831640217455c40c11b9e85e36b470ec05c;hpb=f21dae485bbd4a21104eff49a80b59ce25054bc2;p=lttng-tools.git diff --git a/src/common/consumer.c b/src/common/consumer.c index b5fe98316..370909219 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1960,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); @@ -2012,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 @@ -2969,7 +2973,7 @@ end: } } if (client_socket >= 0) { - ret = close(sock); + ret = close(client_socket); if (ret < 0) { PERROR("close client_socket sessiond poll"); }