consumerd: clean-up: stream attribute accessed without locking stream
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Oct 2019 18:52:44 +0000 (14:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Oct 2019 21:03:19 +0000 (17:03 -0400)
consumer_metadata_cache_flushed makes use of the metadata stream's
ust_metadata_pushed attribute without locking while it is updated by
commit_one_metadata_packet() which holds the metadata stream lock.

This is marked as a clean-up since the attribute appears to always be
accessed while the metadata cache lock is held. However this is a
_channel_ attribute and the stream and channel lifetimes do not match,
making the locking assumptions conceptually dubious.

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

index 65702a2296e1b908702453f9a03b0f14a2bb91ab..5eee4014265f42566776ea34645a0f08504fbde0 100644 (file)
@@ -273,9 +273,9 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
                pthread_mutex_lock(&channel->lock);
        }
        pthread_mutex_lock(&channel->timer_lock);
-       pthread_mutex_lock(&channel->metadata_cache->lock);
-
        metadata_stream = channel->metadata_stream;
+       pthread_mutex_lock(&metadata_stream->lock);
+       pthread_mutex_lock(&channel->metadata_cache->lock);
 
        if (!metadata_stream) {
                /*
@@ -295,6 +295,7 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
        }
 
        pthread_mutex_unlock(&channel->metadata_cache->lock);
+       pthread_mutex_unlock(&metadata_stream->lock);
        pthread_mutex_unlock(&channel->timer_lock);
        if (!timer) {
                pthread_mutex_unlock(&channel->lock);
This page took 0.025782 seconds and 4 git commands to generate.