X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fio-util.c;h=cc6dfa8c1b94a29bcaf36cdb139be8dc09467178;hb=679af4b64de23aec2e8567e7274c86d6895afbc7;hp=3ec8d61236922cb036ed30c7550c893ba7c0f586;hpb=66ecc207e203db5434610395cd04c40ae8727b58;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) {