channel->streams_sent_to_relayd = true;
}
- ret = kernctl_buffer_flush(stream->wait_fd);
+ ret = kernctl_buffer_flush_empty(stream->wait_fd);
if (ret < 0) {
- ERR("Failed to flush kernel stream");
- ret = -errno;
- goto end_unlock;
+ /*
+ * Doing a buffer flush which does not take into
+ * account empty packets. This is not perfect
+ * for stream intersection, but required as a
+ * fall-back when "flush_empty" is not
+ * implemented by lttng-modules.
+ */
+ ret = kernctl_buffer_flush(stream->wait_fd);
+ if (ret < 0) {
+ ERR("Failed to flush kernel stream");
+ goto end_unlock;
+ }
}
ret = lttng_kconsumer_take_snapshot(stream);
return LTTNG_IOCTL(fd, RING_BUFFER_FLUSH);
}
+int kernctl_buffer_flush_empty(int fd)
+{
+ return LTTNG_IOCTL(fd, RING_BUFFER_FLUSH_EMPTY);
+}
+
/* returns the version of the metadata. */
int kernctl_get_metadata_version(int fd, uint64_t *version)
{
int kernctl_put_subbuf(int fd);
int kernctl_buffer_flush(int fd);
+int kernctl_buffer_flush_empty(int fd);
int kernctl_get_metadata_version(int fd, uint64_t *version);
/* index */
#define RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
/* returns the offset of the subbuffer belonging to the mmap reader. */
#define RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
-/* flush the current sub-buffer */
+/* Flush the current sub-buffer, if non-empty. */
#define RING_BUFFER_FLUSH _IO(0xF6, 0x0C)
/* Get the current version of the metadata cache (after a get_next). */
#define RING_BUFFER_GET_METADATA_VERSION _IOR(0xF6, 0x0D, uint64_t)
+/* Flush the current sub-buffer, even if empty. */
+#define RING_BUFFER_FLUSH_EMPTY _IO(0xF6, 0x0F)
/* returns the timestamp begin of the current sub-buffer */
#define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t)