1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

util: loop_write - accept 0-length message

write() can send empty messages, so make sure loop_write() can do the same.
This commit is contained in:
Tom Gundersen 2015-05-16 01:07:45 +02:00
parent 43d60b77a8
commit 8c7e28a191

View File

@ -1664,7 +1664,7 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
errno = 0;
while (nbytes > 0) {
do {
ssize_t k;
k = write(fd, p, nbytes);
@ -1684,12 +1684,12 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
return -errno;
}
if (k == 0) /* Can't really happen */
if (nbytes > 0 && k == 0) /* Can't really happen */
return -EIO;
p += k;
nbytes -= k;
}
} while (nbytes > 0);
return 0;
}