From: Julien Desfossez Date: Mon, 11 Dec 2017 21:42:20 +0000 (-0500) Subject: Dedicated function to wakeup the consumer metadata pipe X-Git-Tag: v2.11.0-rc1~357 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5b8eb761b650749a164de120f014b0cb6c218cf2;p=lttng-tools.git Dedicated function to wakeup the consumer metadata pipe 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/consumer/consumer-metadata-cache.c b/src/common/consumer/consumer-metadata-cache.c index 6b15375e1..ac83443a9 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -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: diff --git a/src/common/consumer/consumer-metadata-cache.h b/src/common/consumer/consumer-metadata-cache.h index 7dcf6976f..d1ca0be2c 100644 --- a/src/common/consumer/consumer-metadata-cache.h +++ b/src/common/consumer/consumer-metadata-cache.h @@ -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 */