diff options
Diffstat (limited to 'lib/latch-unix.c')
-rw-r--r-- | lib/latch-unix.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/latch-unix.c b/lib/latch-unix.c index 2995076d6..f4d10c39a 100644 --- a/lib/latch-unix.c +++ b/lib/latch-unix.c @@ -43,9 +43,17 @@ latch_destroy(struct latch *latch) bool latch_poll(struct latch *latch) { - char buffer[_POSIX_PIPE_BUF]; + char latch_buffer[16]; + bool result = false; + int ret; - return read(latch->fds[0], buffer, sizeof buffer) > 0; + do { + ret = read(latch->fds[0], &latch_buffer, sizeof latch_buffer); + result |= ret > 0; + /* Repeat as long as read() reads a full buffer. */ + } while (ret == sizeof latch_buffer); + + return result; } /* Sets 'latch'. |