summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-16 01:07:45 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 09:57:15 +0100
commit6ec9b87c4ecf5144b5ea845a53a352dd9f2d173a (patch)
tree74fc8ed312d38c3f69b2914e5c99c9eef110008a /src/shared/util.c
parentd2febf7f92eba0919773ce93d80df50fd3faeb5d (diff)
util: loop_write - accept 0-length message
write() can send empty messages, so make sure loop_write() can do the same.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index d7a5b2094..d3dacfcfb 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1665,7 +1665,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);
@@ -1685,12 +1685,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;
}