From 081424af9c3314d41eda58592d9fd6a66d94e852 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 7 Jan 2017 13:42:12 -0500 Subject: [PATCH] Fix: only lock the metadata_cache in userspace consumers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/common/consumer/consumer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 234944dad..3415cfe92 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -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) { -- 2.34.1