On Sat, Jun 12, 2021 at 11:54:58PM -0700, Greg Steuck wrote:
> I started with a failing test for Haskell network package on 6.9-current amd64
> (cabal get network-3.1.2.1 && cabal v2-test)
> 
> network-3.1.2.1/build/spec/spec --match 
> "/Network.Socket.ByteString/recvMsg/works well/"
> 
>   tests/Network/Socket/ByteStringSpec.hs:209:21: 
>   1) Network.Socket.ByteString.recvMsg works well
>        expected: MsgFlag {fromMsgFlag = 0}
>         but got: MsgFlag {fromMsgFlag = 128}
> 
> ktrace says:
> 
>  47649 spec     CALL  sendto(14,0x8a2126e838c,0x16,0,0x8a4a3622df0,0x10)
>  47649 spec     STRU  struct sockaddr { AF_INET, 127.0.0.1:9486 }
>  47649 spec     GIO   fd 14 wrote 22 bytes
>        "This is a test message"
>  47649 spec     RET   sendto 22/0x16
>  47649 spec     CALL  
> futex(0x8a4aef6f930,0x81<FUTEX_WAIT|FUTEX_PRIVATE_FLAG>,1,0,0)
>  47649 spec     STRU  struct kevent { ident=13, filter=EVFILT_READ, 
> flags=0x11<EV_ADD|EV_ONESHOT>, fflags=0<>, data=38, udata=0x0 }
>  47649 spec     RET   kevent 1
>  47649 spec     CALL  recvmsg(13,0x8a4a3622c50,0)
>  47649 spec     GIO   fd 13 read 22 bytes
>        "This is a test message"
>  47649 spec     STRU  struct sockaddr { AF_INET, 127.0.0.1:12293 }
>  47649 spec     STRU  struct msghdr { name=0x8a4a3622b70, namelen=16, 
> iov=0x8a4a3622c30, iovlen=1, control=0x8a4a3622c10, controllen=0, 
> flags=0x80<MSG_DONTWAIT> }
>  47649 spec     STRU  struct iovec { base=0x8a4a3622666, len=1002 }
>  47649 spec     RET   recvmsg 22/0x16
> 
> This seems to contradict recvmsg(2) which doesn't list MSG_DONTWAIT as a
> possible value of the flags. Would this be useful as a C regress test?

Looks like this was missed in sys/kern/uipc_syscalls.c revision 1.178

        date: 2018/07/30 12:22:14;  author: mpi;  state: Exp;  lines: +10 -18;  
commitid: K43aQe66cQkEOSbc;
        Use FNONBLOCK instead of SS_NBIO to check/indicate that the I/O mode
        for sockets is non-blocking.

        This allows us to G/C SS_NBIO.  Having to keep the two flags in sync
        in a mp-safe way is complicated.

        This change introduce a behavior change in sosplice(), it can now
        always block.  However this should not matter much due to the socket
        lock being taken beforhand.

        bluhm@, benno@, visa@

Wording taken from mpi's commit message which is exactly what recvit()
does in one place, i.e.

        if (fp->f_flag & FNONBLOCK)
                mp->msg_flags |= MSG_DONTWAIT;


Here's the documentation bits for it?
Feedback? Objections? OK?


Index: lib/libc/sys/recv.2
===================================================================
RCS file: /cvs/src/lib/libc/sys/recv.2,v
retrieving revision 1.47
diff -u -p -r1.47 recv.2
--- lib/libc/sys/recv.2 11 Jan 2019 06:10:13 -0000      1.47
+++ lib/libc/sys/recv.2 27 Jun 2021 13:30:33 -0000
@@ -248,6 +248,8 @@ for ancillary data.
 Indicates that the packet was received as broadcast.
 .It Dv MSG_MCAST
 Indicates that the packet was received as multicast.
+.It Dv MSG_DONTWAIT
+Indicates that the I/O mode for the socket is non-blocking.
 .El
 .Sh RETURN VALUES
 These calls return the number of bytes received, or \-1 if an error occurred.

Reply via email to