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.9.2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fc9390b19f80ea9fe64783156ea5fdcee8b93817;p=lttng-tools.git 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 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) {