From: Jérémie Galarneau Date: Mon, 8 Feb 2021 18:03:20 +0000 (-0500) Subject: Fix: ust-consumer: metadata cache lock not taken when sampling max offset X-Git-Tag: v2.11.7~25 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3371382d954e609683ac4eec92478a7fbf33ac22;p=lttng-tools.git Fix: ust-consumer: metadata cache lock not taken when sampling max offset 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 --- diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 1283d951c..f3ea024dd 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -3015,7 +3015,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; /*