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>
Tue, 23 Feb 2021 16:08:12 +0000 (11:08 -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 1283d951c11240be6fd1e30ff3a4f808e9534514..f3ea024dd6330e93cf0d38b0a28a78d1daa650b4 100644 (file)
@@ -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;
 
                /*
This page took 0.02742 seconds and 4 git commands to generate.