Fix: lock nesting order reversed
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 7 Jan 2017 17:32:13 +0000 (12:32 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 7 Jan 2017 20:59:47 +0000 (15:59 -0500)
The lttng_consumer_stream lock must nest INSIDE the metadata
cache lock, as indicated in the structure's comments
(see consumer.h:340).

CID 1368314 (#1 of 1): Thread deadlock (ORDER_REVERSAL)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer.c

index 47df32958352b2477a84851bd56875a56696d5fc..21adb00b4d945eaf0255c0f9b2bf100ae1793c2c 100644 (file)
@@ -2052,8 +2052,8 @@ 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);
        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. */
@@ -2079,8 +2079,8 @@ 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->metadata_cache->lock);
        pthread_mutex_unlock(&stream->chan->lock);
+       pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
        pthread_mutex_unlock(&consumer_data.lock);
 
        if (free_chan) {
This page took 0.028656 seconds and 4 git commands to generate.