From 4557dacfbe04206c57e459b734016d2b6edfe7f3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 21 Dec 2014 01:11:18 +0000 Subject: Stricter trynbwaitall to actually catch the problems --- src/sysdeps/trynbwaitall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sysdeps/trynbwaitall.c b/src/sysdeps/trynbwaitall.c index 0f55080..ae79f1c 100644 --- a/src/sysdeps/trynbwaitall.c +++ b/src/sysdeps/trynbwaitall.c @@ -27,6 +27,11 @@ #define MSG_NOSIGNAL 0 #endif +#ifndef MSG_DONTWAIT +#define MSG_DONTWAIT 0 +#endif + + static int ndelay_on (int fd) { register int got = fcntl(fd, F_GETFL) ; @@ -35,8 +40,8 @@ static int ndelay_on (int fd) static int child (int p, int fd) { - char c ; - struct iovec v = { .iov_base = &c, .iov_len = 1 } ; + char buf[8] ; + struct iovec v = { .iov_base = buf, .iov_len = 8 } ; struct msghdr msg = { .msg_name = 0, @@ -56,7 +61,7 @@ static int child (int p, int fd) /* The following recvmsg may block, despite setting the fd non-blocking. That is what we're testing. */ - if (recvmsg(fd, &msg, MSG_WAITALL) < 1) return 111 ; + if (recvmsg(fd, &msg, MSG_WAITALL | MSG_DONTWAIT) < 1) return 111 ; if (write(p, "", 1) < 1) return 111 ; return 0 ; } -- cgit v1.2.3