Fix: add more conditions and a lock to metadata cache flushed
authorDavid Goulet <dgoulet@efficios.com>
Mon, 3 Jun 2013 17:24:10 +0000 (13:24 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 3 Jun 2013 20:52:45 +0000 (16:52 -0400)
Some more conditions applies to return if the metadata cache is indeed
flushed. If no metadata stream is found or the endpoint status is set to
something other than ACTIVE, this means the channel is being (or will
be) destroyed thus the metadata cache can't be updated so is indeed
"flushed".

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/consumer-metadata-cache.c

index 888d82f3accae8e5644c7bb42c4b39747d597e2e..0c20e7fc7cbba6850a3337fc4ebb788d3e5d5f84 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "consumer-metadata-cache.h"
 
+extern struct lttng_consumer_global_data consumer_data;
+
 /*
  * Extend the allocated size of the metadata cache. Called only from
  * lttng_ustconsumer_write_metadata_cache.
@@ -201,13 +203,28 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
 
        cache = channel->metadata_cache;
 
+       pthread_mutex_lock(&consumer_data.lock);
        pthread_mutex_lock(&channel->metadata_cache->lock);
+
        if (cache->rb_pushed >= offset) {
                ret = 0;
+       } else if (!channel->metadata_stream) {
+               /*
+                * Having no metadata stream means the channel is being destroyed so there
+                * is no cache to flush anymore.
+                */
+               ret = 0;
+       } else if (channel->metadata_stream->endpoint_status !=
+                       CONSUMER_ENDPOINT_ACTIVE) {
+               /* An inactive endpoint means we don't have to flush anymore. */
+               ret = 0;
        } else {
+               /* Still not completely flushed. */
                ret = 1;
        }
+
        pthread_mutex_unlock(&channel->metadata_cache->lock);
+       pthread_mutex_unlock(&consumer_data.lock);
 
        return ret;
 }
This page took 0.02565 seconds and 4 git commands to generate.