svn commit: r342768 - in head: lib/libc/sys sys/kern sys/netinet sys/ofed/drivers/infiniband/ulp/sdp

Mark Johnston markj at FreeBSD.org
Fri Jan 4 17:31:51 UTC 2019


Author: markj
Date: Fri Jan  4 17:31:50 2019
New Revision: 342768
URL: https://svnweb.freebsd.org/changeset/base/342768

Log:
  Support MSG_DONTWAIT in send*(2).
  
  As it does for recv*(2), MSG_DONTWAIT indicates that the call should
  not block, returning EAGAIN instead.  Linux and OpenBSD both implement
  this, so the change makes porting easier, especially since we do not
  return EINVAL or so when unrecognized flags are specified.
  
  Submitted by:	Greg V <greg at unrelenting.technology>
  Reviewed by:	tuexen
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D18728

Modified:
  head/lib/libc/sys/send.2
  head/sys/kern/uipc_socket.c
  head/sys/netinet/sctp_output.c
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c

Modified: head/lib/libc/sys/send.2
==============================================================================
--- head/lib/libc/sys/send.2	Fri Jan  4 17:25:47 2019	(r342767)
+++ head/lib/libc/sys/send.2	Fri Jan  4 17:31:50 2019	(r342768)
@@ -28,7 +28,7 @@
 .\"     From: @(#)send.2	8.2 (Berkeley) 2/21/94
 .\" $FreeBSD$
 .\"
-.Dd August 19, 2018
+.Dd January 4, 2019
 .Dt SEND 2
 .Os
 .Sh NAME
@@ -121,7 +121,8 @@ argument may include one or more of the following:
 .Bd -literal
 #define	MSG_OOB		0x00001 /* process out-of-band data */
 #define	MSG_DONTROUTE	0x00004 /* bypass routing, use direct interface */
-#define MSG_EOR		0x00008 /* data completes record */
+#define	MSG_EOR		0x00008 /* data completes record */
+#define	MSG_DONTWAIT	0x00080 /* do not block */
 #define	MSG_EOF		0x00100 /* data completes transaction */
 #define	MSG_NOSIGNAL	0x20000 /* do not generate SIGPIPE on EOF */
 .Ed
@@ -138,6 +139,9 @@ data.
 .Dv MSG_EOR
 is used to indicate a record mark for protocols which support the
 concept.
+The
+.Dv MSG_DONTWAIT
+flag request the call to return when it would block otherwise.
 .Dv MSG_EOF
 requests that the sender side of a socket be shut down, and that an
 appropriate indication be sent at the end of the specified data;
@@ -201,8 +205,9 @@ An invalid user space address was specified for an arg
 The socket requires that message be sent atomically,
 and the size of the message to be sent made this impossible.
 .It Bq Er EAGAIN
-The socket is marked non-blocking and the requested operation
-would block.
+The socket is marked non-blocking, or
+.Dv MSG_DONTWAIT
+is specified, and the requested operation would block.
 .It Bq Er ENOBUFS
 The system was unable to allocate an internal buffer.
 The operation may succeed when buffers become available.

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Fri Jan  4 17:25:47 2019	(r342767)
+++ head/sys/kern/uipc_socket.c	Fri Jan  4 17:31:50 2019	(r342768)
@@ -1522,7 +1522,8 @@ restart:
 		}
 		if (space < resid + clen &&
 		    (atomic || space < so->so_snd.sb_lowat || space < clen)) {
-			if ((so->so_state & SS_NBIO) || (flags & MSG_NBIO)) {
+			if ((so->so_state & SS_NBIO) ||
+			    (flags & (MSG_NBIO | MSG_DONTWAIT)) != 0) {
 				SOCKBUF_UNLOCK(&so->so_snd);
 				error = EWOULDBLOCK;
 				goto release;

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c	Fri Jan  4 17:25:47 2019	(r342767)
+++ head/sys/netinet/sctp_output.c	Fri Jan  4 17:31:50 2019	(r342768)
@@ -12836,7 +12836,7 @@ sctp_lower_sosend(struct socket *so,
 		}
 	}
 	if (SCTP_SO_IS_NBIO(so)
-	    || (flags & MSG_NBIO)
+	    || (flags & (MSG_NBIO | MSG_DONTWAIT)) != 0
 	    ) {
 		non_blocking = 1;
 	}

Modified: head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	Fri Jan  4 17:25:47 2019	(r342767)
+++ head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	Fri Jan  4 17:31:50 2019	(r342768)
@@ -1124,7 +1124,8 @@ restart:
 		}
 		if (space < resid &&
 		    (atomic || space < so->so_snd.sb_lowat)) {
-			if ((so->so_state & SS_NBIO) || (flags & MSG_NBIO)) {
+			if ((so->so_state & SS_NBIO) ||
+			    (flags & (MSG_NBIO | MSG_DONTWAIT)) != 0) {
 				SOCKBUF_UNLOCK(&so->so_snd);
 				error = EWOULDBLOCK;
 				goto release;


More information about the svn-src-head mailing list