X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer%2Fconsumer.c;h=fbbe8ea8fe8907b71db0a59cc5737faad192b04a;hp=5a39a0cc7e22822154ed2c6da334df0c1693355f;hb=a9dde553270b4e8f3f280706e3f19f8f3ac41e1b;hpb=5416a504a1ff9f2444e594084836dc8b59739526 diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 5a39a0cc7..fbbe8ea8f 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -4025,14 +4025,23 @@ int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel, } /* - * Active flush; has no effect if the production position - * is at a packet boundary. + * Do not flush an empty packet when rotating from a NULL trace + * chunk. The stream has no means to output data, and the prior + * rotation which rotated to NULL performed that side-effect already. */ - ret = consumer_flush_buffer(stream, 1); - if (ret < 0) { - ERR("Failed to flush stream %" PRIu64 " during channel rotation", - stream->key); - goto end_unlock_stream; + if (stream->trace_chunk) { + /* + * For metadata stream, do an active flush, which does not + * produce empty packets. For data streams, empty-flush; + * ensures we have at least one packet in each stream per trace + * chunk, even if no data was produced. + */ + ret = consumer_flush_buffer(stream, stream->metadata_flag ? 1 : 0); + if (ret < 0) { + ERR("Failed to flush stream %" PRIu64 " during channel rotation", + stream->key); + goto end_unlock_stream; + } } ret = lttng_consumer_take_snapshot(stream);