Dedicated function to wakeup the consumer metadata pipe
[lttng-tools.git] / src / common / consumer / consumer-metadata-cache.c
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:
This page took 0.025239 seconds and 4 git commands to generate.