Fix: only lock the metadata_cache in userspace consumers
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 7 Jan 2017 18:42:12 +0000 (13:42 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 7 Jan 2017 20:59:41 +0000 (15:59 -0500)
The kernel consumer, which re-uses the consumer_del_metadata_stream
function, has no metadata cache. Therefore, it can't be used to
protect the metadata stream (see 5feafd41).

However, only the userspace consumers invoke
consumer_metadata_cache_write() which the previous fix seeked to
protect against. It is therefore safe to omit this lock in the
kernel consumer case.

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

index 234944dad0abf6d6c6594fa68ea64721f1488d87..3415cfe92872b01d2df95a564dca380db3cc16ce 100644 (file)
@@ -2051,7 +2051,10 @@ 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->metadata_cache->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);
 
@@ -2079,7 +2082,9 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
 
        pthread_mutex_unlock(&stream->lock);
        pthread_mutex_unlock(&stream->chan->lock);
-       pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
+       if (stream->chan->metadata_cache) {
+               pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
+       }
        pthread_mutex_unlock(&consumer_data.lock);
 
        if (free_chan) {
This page took 0.028041 seconds and 4 git commands to generate.