From: Jérémie Galarneau Date: Mon, 28 Oct 2019 18:52:44 +0000 (-0400) Subject: consumerd: clean-up: stream attribute accessed without locking stream X-Git-Tag: v2.12.0-rc1~275 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=8e1ef46e89a86865736a62d2def88f70acb0be55;ds=sidebyside consumerd: clean-up: stream attribute accessed without locking stream 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 --- diff --git a/src/common/consumer/consumer-metadata-cache.c b/src/common/consumer/consumer-metadata-cache.c index 65702a229..5eee40142 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -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);