Dedicated function to wakeup the consumer metadata pipe
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 11 Dec 2017 21:42:20 +0000 (16:42 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 8 Mar 2018 21:57:48 +0000 (16:57 -0500)
Extract the logic to wakeup the consumer metadata pipe to a dedicated
function, it will be used after a rotation in UST.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer-metadata-cache.c
src/common/consumer/consumer-metadata-cache.h

index 6b15375e19c27d52ae31b991d13bfc6f52838088..ac83443a9500856f17230563511bba6270dd00c7 100644 (file)
@@ -105,6 +105,31 @@ 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(const struct lttng_consumer_channel *channel)
+{
+       int ret = 0;
+       const char dummy = 'c';
+
+       if (channel->monitor && channel->metadata_stream) {
+               ssize_t write_ret;
+
+               write_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
+                               &dummy, 1);
+               if (write_ret < 1) {
+                       PERROR("Wake-up 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 +143,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 +168,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..d1ca0be2c199a0b824ca7dab7c4e4a59b1ec3fe6 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(const struct lttng_consumer_channel *channel);
 
 #endif /* CONSUMER_METADATA_CACHE_H */
This page took 0.035928 seconds and 4 git commands to generate.