summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2012-10-05 01:30:29 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2012-10-05 01:30:29 +0000
commitc7a4c09ccbc47a77820c2a19817c8cc68edf7fdc (patch)
tree1d53fe42675f0ffe869c617e8b2775e6e95e8815
parentdd981556ae4c448d80e745de77182732693c252d (diff)
add send(2) MSG_DONTWAIT support which enables us to choose nonblocking
or blocking for each send(2) call. diff from UMEZAWA Takeshi ok bluhm
-rw-r--r--lib/libc/sys/send.26
-rw-r--r--sys/kern/uipc_socket.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2
index d58588f5c91..d91d2b8053a 100644
--- a/lib/libc/sys/send.2
+++ b/lib/libc/sys/send.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: send.2,v 1.26 2012/04/11 14:08:27 deraadt Exp $
+.\" $OpenBSD: send.2,v 1.27 2012/10/05 01:30:28 yasuoka Exp $
.\" $NetBSD: send.2,v 1.6 1996/01/15 01:17:18 thorpej Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)send.2 8.2 (Berkeley) 2/21/94
.\"
-.Dd $Mdocdate: April 11 2012 $
+.Dd $Mdocdate: October 5 2012 $
.Dt SEND 2
.Os
.Sh NAME
@@ -103,6 +103,8 @@ bypass routing, use direct interface
.It Dv MSG_NOSIGNAL
don't send
.Dv SIGPIPE
+.It Dv MSG_DONTWAIT
+don't block
.El
.Pp
The flag
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index de3c9f01cf3..9972abca17b 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.108 2012/09/20 12:34:18 bluhm Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.109 2012/10/05 01:30:28 yasuoka Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -451,7 +451,7 @@ restart:
snderr(EMSGSIZE);
if (space < resid + clen &&
(atomic || space < so->so_snd.sb_lowat || space < clen)) {
- if (so->so_state & SS_NBIO)
+ if ((so->so_state & SS_NBIO) || (flags & MSG_DONTWAIT))
snderr(EWOULDBLOCK);
sbunlock(&so->so_snd);
error = sbwait(&so->so_snd);