From: Jérémie Galarneau Date: Sat, 7 Jan 2017 18:42:12 +0000 (-0500) Subject: Fix: only lock the metadata_cache in userspace consumers X-Git-Tag: v2.8.5~1 X-Git-Url: https://git.liburcu.org/?p=lttng-tools.git;a=commitdiff_plain;h=4486a5729f7938cd4aa4c936c8cd8ba71f69534e Fix: only lock the metadata_cache in userspace consumers 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 --- diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 21adb00b4..19d705c93 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -2052,7 +2052,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); @@ -2080,7 +2083,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) {