aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-01-31 20:41:38 -0800
committerGuy Harris <guy@alum.mit.edu>2017-02-01 04:43:04 +0000
commit11ce17f0a66365ece3c5cf043c4dccf5cdf8df9f (patch)
tree1fbaf58735b33799944f78ed47149b977389712d /sharkd_session.c
parent2b91f04008530039e830da5f820c6d449a9d5c4d (diff)
Expand a comment to give more details.
(Dear Microsoft: why did you choose not to support line buffering in the MSVC "standard I/O library" routines?) Change-Id: I5add94d2c83e73e9845fea0f355a1923fddf2deb Reviewed-on: https://code.wireshark.org/review/19890 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'sharkd_session.c')
-rw-r--r--sharkd_session.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index faddaa364a..2f5c0334fc 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -1885,7 +1885,20 @@ sharkd_session_process(char *buf, const jsmntok_t *tokens, int count)
/* reply for every command are 0+ lines of JSON reply (outputed above), finished by empty new line */
printf("\n");
- /* stdout is on most systems buffered, fflush() to output reply to a socket */
+ /*
+ * We do an explicit fflush after every line, because
+ * we want output to be written to the socket as soon
+ * as the line is complete.
+ *
+ * The stream is fully-buffered by default, so it's
+ * only flushed when the buffer fills or the FILE *
+ * is closed. On UN*X, we could set it to be line
+ * buffered, but the MSVC standard I/O routines don't
+ * support line buffering - they only support *byte*
+ * buffering, doing a write for every byte written,
+ * which is too inefficient, and full buffering,
+ * which is what you get if you request line buffering.
+ */
fflush(stdout);
}
}