From 8dcb4e83662ffac2b204f9bfcc28bbd914edf390 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 13 Dec 2016 12:17:10 -0500 Subject: [PATCH] Fix: perform an explicit stdout flush in live even on empty packets MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This ensures that babeltrace makes the content of live buffers visible even if the data packets received are empty. Signed-off-by: Jérémie Galarneau --- formats/lttng-live/lttng-live-comm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index 7b4711be..6b65512c 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -650,17 +650,6 @@ retry: goto end; } - /* - * Flush the output between attempts to grab a packet, thus - * ensuring we flush at least at the periodical timer period. - * This ensures the output remains reactive for interactive users and - * that the output is flushed when redirected to a file by the shell. - */ - if (fflush(LTTNG_LIVE_OUTPUT_FP) < 0) { - perror("fflush"); - goto error; - } - cmd.cmd = htobe32(LTTNG_VIEWER_GET_PACKET); cmd.data_size = htobe64((uint64_t) sizeof(rq)); cmd.cmd_version = htobe32(0); @@ -1293,6 +1282,17 @@ retry: cur_index->ts_real.timestamp_begin; } + /* + * Flush the output between attempts to grab a packet, thus + * ensuring we flush at least at the periodical timer period. + * This ensures the output remains reactive for interactive users and + * that the output is flushed when redirected to a file by the shell. + */ + if (fflush(LTTNG_LIVE_OUTPUT_FP) < 0) { + perror("fflush"); + goto end; + } + if (pos->packet_size == 0 || pos->offset == EOF) { goto end; } -- 2.34.1