From: Jérémie Galarneau Date: Sun, 8 Jan 2017 19:29:09 +0000 (-0500) Subject: Fix: reverse channel and metadata cache lock nesting order X-Git-Tag: v2.8.6~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=69018d12995a4fb76285cd77e9ad013ac81c0b27;p=lttng-tools.git Fix: reverse channel and metadata cache lock nesting order CID 1368319: Program hangs (ORDER_REVERSAL) The lttng_consumer_channel lock must be nested outside of the metadata cache lock, as indicated in the structure's comments. Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 19d705c93..bfec997ee 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -2052,11 +2052,11 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, DBG3("Consumer delete metadata stream %d", stream->wait_fd); pthread_mutex_lock(&consumer_data.lock); + pthread_mutex_lock(&stream->chan->lock); if (stream->chan->metadata_cache) { /* Only applicable to userspace consumers. */ pthread_mutex_lock(&stream->chan->metadata_cache->lock); } - pthread_mutex_lock(&stream->chan->lock); pthread_mutex_lock(&stream->lock); /* Remove any reference to that stream. */ @@ -2082,10 +2082,10 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, stream->chan->metadata_stream = NULL; pthread_mutex_unlock(&stream->lock); - pthread_mutex_unlock(&stream->chan->lock); if (stream->chan->metadata_cache) { pthread_mutex_unlock(&stream->chan->metadata_cache->lock); } + pthread_mutex_unlock(&stream->chan->lock); pthread_mutex_unlock(&consumer_data.lock); if (free_chan) {