mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-22 11:17:19 +00:00
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@unrelenting.technology> Reviewed by: tuexen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D18728
This commit is contained in:
parent
f0d85a5dc5
commit
2f2ddd68a5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=342768
@ -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 argument.
|
||||
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.
|
||||
|
@ -1522,7 +1522,8 @@ sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio,
|
||||
}
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1124,7 +1124,8 @@ sdp_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
|
||||
}
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user