skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 4557dacfbe04206c57e459b734016d2b6edfe7f3
parent 23bdcb4ad4ef19d99b729e5282fd15df6300a3b5
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sun, 21 Dec 2014 01:11:18 +0000

 Stricter trynbwaitall to actually catch the problems

Diffstat:
Msrc/sysdeps/trynbwaitall.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 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 ; }