Fix: reverse channel and metadata cache lock nesting order
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 8 Jan 2017 19:29:09 +0000 (14:29 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 9 Jan 2017 17:34:34 +0000 (12:34 -0500)
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 <jeremie.galarneau@efficios.com>
src/common/consumer/consumer.c

index 19d705c93c1b674e67a42975b0ce4cc84d577a73..bfec997eec808019f28283aa2a42f6fdd7baf913 100644 (file)
@@ -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) {
This page took 0.031072 seconds and 4 git commands to generate.