Common code to wakeup the metadata pipe
authorJulien Desfossez <jdesfossez@efficios.com>
Tue, 25 Jul 2017 18:13:00 +0000 (14:13 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Wed, 30 Aug 2017 19:29:02 +0000 (15:29 -0400)
We need to be able to wakeup the metadata thread when the rotation of a
metadata stream is complete.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/common/consumer/consumer-metadata-cache.c
src/common/consumer/consumer-metadata-cache.h

index 6b15375e19c27d52ae31b991d13bfc6f52838088..156412977523128e9f4daab74756aa48e04a4026 100644 (file)
@@ -105,6 +105,30 @@ end:
        return ret;
 }
 
+/*
+ * Write a character on the metadata poll pipe to wake the metadata thread.
+ * Returns 0 on success, -1 on error.
+ */
+int consumer_metadata_wakeup_pipe(struct lttng_consumer_channel *channel)
+{
+       char dummy = 'c';
+       int ret = 0;
+       int size_ret;
+
+       if (channel->monitor && channel->metadata_stream) {
+               size_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
+                               &dummy, 1);
+               if (size_ret < 1) {
+                       ERR("Wakeup UST metadata pipe");
+                       ret = -1;
+                       goto end;
+               }
+       }
+
+end:
+       return ret;
+}
+
 /*
  * Write metadata to the cache, extend the cache if necessary. We support
  * overlapping updates, but they need to be contiguous. Send the
@@ -118,7 +142,6 @@ int consumer_metadata_cache_write(struct lttng_consumer_channel *channel,
                char *data)
 {
        int ret = 0;
-       int size_ret;
        struct consumer_metadata_cache *cache;
 
        assert(channel);
@@ -144,18 +167,8 @@ int consumer_metadata_cache_write(struct lttng_consumer_channel *channel,
 
        memcpy(cache->data + offset, data, len);
        if (offset + len > cache->max_offset) {
-               char dummy = 'c';
-
                cache->max_offset = offset + len;
-               if (channel->monitor && channel->metadata_stream) {
-                       size_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
-                                       &dummy, 1);
-                       if (size_ret < 1) {
-                               ERR("Wakeup UST metadata pipe");
-                               ret = -1;
-                               goto end;
-                       }
-               }
+               ret = consumer_metadata_wakeup_pipe(channel);
        }
 
 end:
index 7dcf6976f3ada26eb4adf05beba86e710bc28752..f12175b68d195403a7daa6cc1bc8611feef8dabf 100644 (file)
@@ -52,5 +52,6 @@ int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
 void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
 int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
                uint64_t offset, int timer);
+int consumer_metadata_wakeup_pipe(struct lttng_consumer_channel *channel);
 
 #endif /* CONSUMER_METADATA_CACHE_H */
This page took 0.029133 seconds and 5 git commands to generate.