summaryrefslogtreecommitdiff
path: root/src/libbasic/io-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libbasic/io-util.c')
-rw-r--r--src/libbasic/io-util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libbasic/io-util.c b/src/libbasic/io-util.c
index 3ec8d61236..cc6dfa8c1b 100644
--- a/src/libbasic/io-util.c
+++ b/src/libbasic/io-util.c
@@ -33,6 +33,11 @@ int flush_fd(int fd) {
.events = POLLIN,
};
+ /* Read from the specified file descriptor, until POLLIN is not set anymore, throwing away everything
+ * read. Note that some file descriptors (notable IP sockets) will trigger POLLIN even when no data can be read
+ * (due to IP packet checksum mismatches), hence this function is only safe to be non-blocking if the fd used
+ * was set to non-blocking too. */
+
for (;;) {
char buf[LINE_MAX];
ssize_t l;
@@ -249,7 +254,7 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
} else if (n > 0)
q += n;
else
- q ++;
+ q++;
}
if (q > w) {