Fix: perform an explicit stdout flush in live even on empty packets
[babeltrace.git] / formats / lttng-live / lttng-live-comm.c
index 7b4711be06095bafdaf7d9ca3126fda5b4d34483..6b65512ca3219dd9096f36293ba2a797a8574ef5 100644 (file)
@@ -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;
        }
This page took 0.02327 seconds and 4 git commands to generate.