X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fbasic%2Fio-util.c;h=cc6dfa8c1b94a29bcaf36cdb139be8dc09467178;hb=90d6a4ed9d3ef81bad45801bfebe7446ee9d08ef;hp=3ec8d61236922cb036ed30c7550c893ba7c0f586;hpb=07045a1a92c839fd2af80bd0c060a595021bc3b3;p=elogind.git diff --git a/src/basic/io-util.c b/src/basic/io-util.c index 3ec8d6123..cc6dfa8c1 100644 --- a/src/basic/io-util.c +++ b/src/basic/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) {