From 934ba8fdfbe546a25a9df61b6292bdb3d28e4ab1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 8 Feb 2021 13:03:20 -0500 Subject: [PATCH] Fix: ust-consumer: metadata cache lock not taken when sampling max offset MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Found by inspecting the code while searching for an unrelated problem. The 'max_offset' field is probably only accessed by the sessiond poll thread, but this isn't a documented (nor reasonably maintainable) guarantee. Signed-off-by: Jérémie Galarneau Change-Id: I1d2b29e9a483aa8e49c2db589284b853cce65491 --- src/common/ust-consumer/ust-consumer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 6a0942e4e..be0019174 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -3063,7 +3063,9 @@ int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream) uint64_t contiguous, pushed; /* Ease our life a bit. */ + pthread_mutex_lock(&stream->chan->metadata_cache->lock); contiguous = stream->chan->metadata_cache->max_offset; + pthread_mutex_unlock(&stream->chan->metadata_cache->lock); pushed = stream->ust_metadata_pushed; /* -- 2.34.1