Fix: ust-consumer: metadata cache lock not taken when sampling max offset
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 8 Feb 2021 18:03:20 +0000 (13:03 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Feb 2021 16:41:43 +0000 (11:41 -0500)
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 <jeremie.galarneau@efficios.com>
Change-Id: I1d2b29e9a483aa8e49c2db589284b853cce65491

src/common/ust-consumer/ust-consumer.c

index 209931f5644a3d74dc27ed1a8f7dbb3d3863d387..e522de750275e08ff366b27ab31d64407b62b1c2 100644 (file)
@@ -3054,7 +3054,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;
 
                /*
This page took 0.027927 seconds and 4 git commands to generate.