- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state. - Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis - Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets. - Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all errors?).diff -r1.110 -r1.111 src/sys/compat/linux/common/linux_socket.c
(christos)
--- src/sys/compat/linux/common/linux_socket.c 2011/07/17 23:59:54 1.110
+++ src/sys/compat/linux/common/linux_socket.c 2011/12/20 23:56:28 1.111
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $ */ | 1 | /* $NetBSD: linux_socket.c,v 1.111 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Frank van der Linden and Eric Haszlakiewicz. | 8 | * by Frank van der Linden and Eric Haszlakiewicz. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Functions in multiarch: | 33 | * Functions in multiarch: | |
34 | * linux_sys_socketcall : linux_socketcall.c | 34 | * linux_sys_socketcall : linux_socketcall.c | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.111 2011/12/20 23:56:28 christos Exp $"); | |
39 | 39 | |||
40 | #if defined(_KERNEL_OPT) | 40 | #if defined(_KERNEL_OPT) | |
41 | #include "opt_inet.h" | 41 | #include "opt_inet.h" | |
42 | #endif /* defined(_KERNEL_OPT) */ | 42 | #endif /* defined(_KERNEL_OPT) */ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/buf.h> | 47 | #include <sys/buf.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/malloc.h> | |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> | |
50 | #include <sys/tty.h> | 50 | #include <sys/tty.h> | |
51 | #include <sys/file.h> | 51 | #include <sys/file.h> | |
@@ -1366,44 +1366,44 @@ linux_sys_connect(struct lwp *l, const s | @@ -1366,44 +1366,44 @@ linux_sys_connect(struct lwp *l, const s | |||
1366 | } */ | 1366 | } */ | |
1367 | int error; | 1367 | int error; | |
1368 | struct mbuf *nam; | 1368 | struct mbuf *nam; | |
1369 | 1369 | |||
1370 | error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, name), | 1370 | error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, name), | |
1371 | SCARG(uap, namelen)); | 1371 | SCARG(uap, namelen)); | |
1372 | if (error) | 1372 | if (error) | |
1373 | return (error); | 1373 | return (error); | |
1374 | 1374 | |||
1375 | error = do_sys_connect(l, SCARG(uap, s), nam); | 1375 | error = do_sys_connect(l, SCARG(uap, s), nam); | |
1376 | 1376 | |||
1377 | if (error == EISCONN) { | 1377 | if (error == EISCONN) { | |
1378 | struct socket *so; | 1378 | struct socket *so; | |
1379 | int state, prflags, nbio; | 1379 | int state, prflags; | |
1380 | 1380 | |||
1381 | /* fd_getsock() will use the descriptor for us */ | 1381 | /* fd_getsock() will use the descriptor for us */ | |
1382 | if (fd_getsock(SCARG(uap, s), &so) != 0) | 1382 | if (fd_getsock(SCARG(uap, s), &so) != 0) | |
1383 | return EISCONN; | 1383 | return EISCONN; | |
1384 | 1384 | |||
1385 | solock(so); | 1385 | solock(so); | |
1386 | state = so->so_state; | 1386 | state = so->so_state; | |
1387 | nbio = so->so_nbio; | |||
1388 | prflags = so->so_proto->pr_flags; | 1387 | prflags = so->so_proto->pr_flags; | |
1389 | sounlock(so); | 1388 | sounlock(so); | |
1390 | fd_putfile(SCARG(uap, s)); | 1389 | fd_putfile(SCARG(uap, s)); | |
1391 | /* | 1390 | /* | |
1392 | * We should only let this call succeed once per | 1391 | * We should only let this call succeed once per | |
1393 | * non-blocking connect; however we don't have | 1392 | * non-blocking connect; however we don't have | |
1394 | * a convenient place to keep that state.. | 1393 | * a convenient place to keep that state.. | |
1395 | */ | 1394 | */ | |
1396 | if (nbio && (state & SS_ISCONNECTED) && | 1395 | if ((state & (SS_ISCONNECTED|SS_NBIO)) == | |
1396 | (SS_ISCONNECTED|SS_NBIO) && | |||
1397 | (prflags & PR_CONNREQUIRED)) | 1397 | (prflags & PR_CONNREQUIRED)) | |
1398 | return 0; | 1398 | return 0; | |
1399 | } | 1399 | } | |
1400 | 1400 | |||
1401 | return (error); | 1401 | return (error); | |
1402 | } | 1402 | } | |
1403 | 1403 | |||
1404 | int | 1404 | int | |
1405 | linux_sys_bind(struct lwp *l, const struct linux_sys_bind_args *uap, register_t *retval) | 1405 | linux_sys_bind(struct lwp *l, const struct linux_sys_bind_args *uap, register_t *retval) | |
1406 | { | 1406 | { | |
1407 | /* { | 1407 | /* { | |
1408 | syscallarg(int) s; | 1408 | syscallarg(int) s; | |
1409 | syscallarg(const struct osockaddr *) name; | 1409 | syscallarg(const struct osockaddr *) name; |
--- src/sys/dev/kttcp.c 2008/04/24 11:38:36 1.28
+++ src/sys/dev/kttcp.c 2011/12/20 23:56:28 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: kttcp.c,v 1.28 2008/04/24 11:38:36 ad Exp $ */ | 1 | /* $NetBSD: kttcp.c,v 1.29 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002 Wasabi Systems, Inc. | 4 | * Copyright (c) 2002 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Frank van der Linden and Jason R. Thorpe for | 7 | * Written by Frank van der Linden and Jason R. Thorpe for | |
8 | * Wasabi Systems, Inc. | 8 | * Wasabi Systems, Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -32,27 +32,27 @@ | @@ -32,27 +32,27 @@ | |||
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * kttcp.c -- provides kernel support for testing network testing, | 40 | * kttcp.c -- provides kernel support for testing network testing, | |
41 | * see kttcp(4) | 41 | * see kttcp(4) | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/cdefs.h> | 44 | #include <sys/cdefs.h> | |
45 | __KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.28 2008/04/24 11:38:36 ad Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.29 2011/12/20 23:56:28 christos Exp $"); | |
46 | 46 | |||
47 | #include <sys/param.h> | 47 | #include <sys/param.h> | |
48 | #include <sys/types.h> | 48 | #include <sys/types.h> | |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> | |
50 | #include <sys/file.h> | 50 | #include <sys/file.h> | |
51 | #include <sys/filedesc.h> | 51 | #include <sys/filedesc.h> | |
52 | #include <sys/conf.h> | 52 | #include <sys/conf.h> | |
53 | #include <sys/systm.h> | 53 | #include <sys/systm.h> | |
54 | #include <sys/protosw.h> | 54 | #include <sys/protosw.h> | |
55 | #include <sys/proc.h> | 55 | #include <sys/proc.h> | |
56 | #include <sys/resourcevar.h> | 56 | #include <sys/resourcevar.h> | |
57 | #include <sys/signal.h> | 57 | #include <sys/signal.h> | |
58 | #include <sys/socketvar.h> | 58 | #include <sys/socketvar.h> | |
@@ -227,27 +227,27 @@ kttcp_sosend(struct socket *so, unsigned | @@ -227,27 +227,27 @@ kttcp_sosend(struct socket *so, unsigned | |||
227 | if ((so->so_state & SS_ISCONNECTED) == 0) { | 227 | if ((so->so_state & SS_ISCONNECTED) == 0) { | |
228 | if (so->so_proto->pr_flags & PR_CONNREQUIRED) { | 228 | if (so->so_proto->pr_flags & PR_CONNREQUIRED) { | |
229 | if ((so->so_state & SS_ISCONFIRMING) == 0) | 229 | if ((so->so_state & SS_ISCONFIRMING) == 0) | |
230 | snderr(ENOTCONN); | 230 | snderr(ENOTCONN); | |
231 | } else | 231 | } else | |
232 | snderr(EDESTADDRREQ); | 232 | snderr(EDESTADDRREQ); | |
233 | } | 233 | } | |
234 | space = sbspace(&so->so_snd); | 234 | space = sbspace(&so->so_snd); | |
235 | if (flags & MSG_OOB) | 235 | if (flags & MSG_OOB) | |
236 | space += 1024; | 236 | space += 1024; | |
237 | if ((atomic && resid > so->so_snd.sb_hiwat)) | 237 | if ((atomic && resid > so->so_snd.sb_hiwat)) | |
238 | snderr(EMSGSIZE); | 238 | snderr(EMSGSIZE); | |
239 | if (space < resid && (atomic || space < so->so_snd.sb_lowat)) { | 239 | if (space < resid && (atomic || space < so->so_snd.sb_lowat)) { | |
240 | if (so->so_nbio) | 240 | if (so->so_state & SS_NBIO) | |
241 | snderr(EWOULDBLOCK); | 241 | snderr(EWOULDBLOCK); | |
242 | SBLASTRECORDCHK(&so->so_rcv, | 242 | SBLASTRECORDCHK(&so->so_rcv, | |
243 | "kttcp_soreceive sbwait 1"); | 243 | "kttcp_soreceive sbwait 1"); | |
244 | SBLASTMBUFCHK(&so->so_rcv, | 244 | SBLASTMBUFCHK(&so->so_rcv, | |
245 | "kttcp_soreceive sbwait 1"); | 245 | "kttcp_soreceive sbwait 1"); | |
246 | sbunlock(&so->so_snd); | 246 | sbunlock(&so->so_snd); | |
247 | error = sbwait(&so->so_snd); | 247 | error = sbwait(&so->so_snd); | |
248 | if (error) | 248 | if (error) | |
249 | goto out; | 249 | goto out; | |
250 | goto restart; | 250 | goto restart; | |
251 | } | 251 | } | |
252 | mp = ⊤ | 252 | mp = ⊤ | |
253 | do { | 253 | do { | |
@@ -417,27 +417,27 @@ kttcp_soreceive(struct socket *so, unsig | @@ -417,27 +417,27 @@ kttcp_soreceive(struct socket *so, unsig | |||
417 | } | 417 | } | |
418 | for (; m; m = m->m_next) | 418 | for (; m; m = m->m_next) | |
419 | if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) { | 419 | if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) { | |
420 | m = so->so_rcv.sb_mb; | 420 | m = so->so_rcv.sb_mb; | |
421 | goto dontblock; | 421 | goto dontblock; | |
422 | } | 422 | } | |
423 | if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 && | 423 | if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 && | |
424 | (so->so_proto->pr_flags & PR_CONNREQUIRED)) { | 424 | (so->so_proto->pr_flags & PR_CONNREQUIRED)) { | |
425 | error = ENOTCONN; | 425 | error = ENOTCONN; | |
426 | goto release; | 426 | goto release; | |
427 | } | 427 | } | |
428 | if (resid == 0) | 428 | if (resid == 0) | |
429 | goto release; | 429 | goto release; | |
430 | if (so->so_nbio || (flags & MSG_DONTWAIT)) { | 430 | if ((so->so_so_state & SS_NBIO) || (flags & MSG_DONTWAIT|MSG_NBIO)) { | |
431 | error = EWOULDBLOCK; | 431 | error = EWOULDBLOCK; | |
432 | goto release; | 432 | goto release; | |
433 | } | 433 | } | |
434 | sbunlock(&so->so_rcv); | 434 | sbunlock(&so->so_rcv); | |
435 | error = sbwait(&so->so_rcv); | 435 | error = sbwait(&so->so_rcv); | |
436 | if (error) { | 436 | if (error) { | |
437 | sounlock(so); | 437 | sounlock(so); | |
438 | return (error); | 438 | return (error); | |
439 | } | 439 | } | |
440 | goto restart; | 440 | goto restart; | |
441 | } | 441 | } | |
442 | dontblock: | 442 | dontblock: | |
443 | /* | 443 | /* |
--- src/sys/kern/sys_socket.c 2011/06/30 22:38:50 1.64
+++ src/sys/kern/sys_socket.c 2011/12/20 23:56:28 1.65
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sys_socket.c,v 1.64 2011/06/30 22:38:50 dyoung Exp $ */ | 1 | /* $NetBSD: sys_socket.c,v 1.65 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
58 | * SUCH DAMAGE. | 58 | * SUCH DAMAGE. | |
59 | * | 59 | * | |
60 | * @(#)sys_socket.c 8.3 (Berkeley) 2/14/95 | 60 | * @(#)sys_socket.c 8.3 (Berkeley) 2/14/95 | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.64 2011/06/30 22:38:50 dyoung Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.65 2011/12/20 23:56:28 christos Exp $"); | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/systm.h> | 67 | #include <sys/systm.h> | |
68 | #include <sys/systm.h> | 68 | #include <sys/systm.h> | |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> | |
70 | #include <sys/mbuf.h> | 70 | #include <sys/mbuf.h> | |
71 | #include <sys/protosw.h> | 71 | #include <sys/protosw.h> | |
72 | #include <sys/socket.h> | 72 | #include <sys/socket.h> | |
73 | #include <sys/socketvar.h> | 73 | #include <sys/socketvar.h> | |
74 | #include <sys/ioctl.h> | 74 | #include <sys/ioctl.h> | |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> | |
76 | #include <sys/poll.h> | 76 | #include <sys/poll.h> | |
77 | #include <sys/proc.h> | 77 | #include <sys/proc.h> | |
@@ -117,28 +117,32 @@ soo_write(file_t *fp, off_t *offset, str | @@ -117,28 +117,32 @@ soo_write(file_t *fp, off_t *offset, str | |||
117 | 117 | |||
118 | return error; | 118 | return error; | |
119 | } | 119 | } | |
120 | 120 | |||
121 | int | 121 | int | |
122 | soo_ioctl(file_t *fp, u_long cmd, void *data) | 122 | soo_ioctl(file_t *fp, u_long cmd, void *data) | |
123 | { | 123 | { | |
124 | struct socket *so = fp->f_data; | 124 | struct socket *so = fp->f_data; | |
125 | int error = 0; | 125 | int error = 0; | |
126 | 126 | |||
127 | switch (cmd) { | 127 | switch (cmd) { | |
128 | 128 | |||
129 | case FIONBIO: | 129 | case FIONBIO: | |
130 | /* No reason to lock and this call is made very often. */ | 130 | solock(so); | |
131 | so->so_nbio = *(int *)data; | 131 | if (*(int *)data) | |
132 | so->so_state |= SS_NBIO; | |||
133 | else | |||
134 | so->so_state &= ~SS_NBIO; | |||
135 | sounlock(so); | |||
132 | break; | 136 | break; | |
133 | 137 | |||
134 | case FIOASYNC: | 138 | case FIOASYNC: | |
135 | solock(so); | 139 | solock(so); | |
136 | if (*(int *)data) { | 140 | if (*(int *)data) { | |
137 | so->so_state |= SS_ASYNC; | 141 | so->so_state |= SS_ASYNC; | |
138 | so->so_rcv.sb_flags |= SB_ASYNC; | 142 | so->so_rcv.sb_flags |= SB_ASYNC; | |
139 | so->so_snd.sb_flags |= SB_ASYNC; | 143 | so->so_snd.sb_flags |= SB_ASYNC; | |
140 | } else { | 144 | } else { | |
141 | so->so_state &= ~SS_ASYNC; | 145 | so->so_state &= ~SS_ASYNC; | |
142 | so->so_rcv.sb_flags &= ~SB_ASYNC; | 146 | so->so_rcv.sb_flags &= ~SB_ASYNC; | |
143 | so->so_snd.sb_flags &= ~SB_ASYNC; | 147 | so->so_snd.sb_flags &= ~SB_ASYNC; | |
144 | } | 148 | } |
--- src/sys/kern/uipc_socket.c 2011/07/02 17:53:50 1.205
+++ src/sys/kern/uipc_socket.c 2011/12/20 23:56:28 1.206
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uipc_socket.c,v 1.205 2011/07/02 17:53:50 bouyer Exp $ */ | 1 | /* $NetBSD: uipc_socket.c,v 1.206 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. | 8 | * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -53,27 +53,27 @@ | @@ -53,27 +53,27 @@ | |||
53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 | * SUCH DAMAGE. | 60 | * SUCH DAMAGE. | |
61 | * | 61 | * | |
62 | * @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 | 62 | * @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 | |
63 | */ | 63 | */ | |
64 | 64 | |||
65 | #include <sys/cdefs.h> | 65 | #include <sys/cdefs.h> | |
66 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.205 2011/07/02 17:53:50 bouyer Exp $"); | 66 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.206 2011/12/20 23:56:28 christos Exp $"); | |
67 | 67 | |||
68 | #include "opt_compat_netbsd.h" | 68 | #include "opt_compat_netbsd.h" | |
69 | #include "opt_sock_counters.h" | 69 | #include "opt_sock_counters.h" | |
70 | #include "opt_sosend_loan.h" | 70 | #include "opt_sosend_loan.h" | |
71 | #include "opt_mbuftrace.h" | 71 | #include "opt_mbuftrace.h" | |
72 | #include "opt_somaxkva.h" | 72 | #include "opt_somaxkva.h" | |
73 | #include "opt_multiprocessor.h" /* XXX */ | 73 | #include "opt_multiprocessor.h" /* XXX */ | |
74 | 74 | |||
75 | #include <sys/param.h> | 75 | #include <sys/param.h> | |
76 | #include <sys/systm.h> | 76 | #include <sys/systm.h> | |
77 | #include <sys/proc.h> | 77 | #include <sys/proc.h> | |
78 | #include <sys/file.h> | 78 | #include <sys/file.h> | |
79 | #include <sys/filedesc.h> | 79 | #include <sys/filedesc.h> | |
@@ -731,27 +731,28 @@ soclose(struct socket *so) | @@ -731,27 +731,28 @@ soclose(struct socket *so) | |||
731 | } | 731 | } | |
732 | break; | 732 | break; | |
733 | } | 733 | } | |
734 | } | 734 | } | |
735 | if (so->so_pcb == 0) | 735 | if (so->so_pcb == 0) | |
736 | goto discard; | 736 | goto discard; | |
737 | if (so->so_state & SS_ISCONNECTED) { | 737 | if (so->so_state & SS_ISCONNECTED) { | |
738 | if ((so->so_state & SS_ISDISCONNECTING) == 0) { | 738 | if ((so->so_state & SS_ISDISCONNECTING) == 0) { | |
739 | error = sodisconnect(so); | 739 | error = sodisconnect(so); | |
740 | if (error) | 740 | if (error) | |
741 | goto drop; | 741 | goto drop; | |
742 | } | 742 | } | |
743 | if (so->so_options & SO_LINGER) { | 743 | if (so->so_options & SO_LINGER) { | |
744 | if ((so->so_state & SS_ISDISCONNECTING) && so->so_nbio) | 744 | if ((so->so_state & (SS_ISDISCONNECTING|SS_NBIO)) == | |
745 | (SS_ISDISCONNECTING|SS_NBIO)) | |||
745 | goto drop; | 746 | goto drop; | |
746 | while (so->so_state & SS_ISCONNECTED) { | 747 | while (so->so_state & SS_ISCONNECTED) { | |
747 | error = sowait(so, true, so->so_linger * hz); | 748 | error = sowait(so, true, so->so_linger * hz); | |
748 | if (error) | 749 | if (error) | |
749 | break; | 750 | break; | |
750 | } | 751 | } | |
751 | } | 752 | } | |
752 | } | 753 | } | |
753 | drop: | 754 | drop: | |
754 | if (so->so_pcb) { | 755 | if (so->so_pcb) { | |
755 | error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, | 756 | error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, | |
756 | NULL, NULL, NULL, NULL); | 757 | NULL, NULL, NULL, NULL); | |
757 | if (error == 0) | 758 | if (error == 0) | |
@@ -951,27 +952,27 @@ sosend(struct socket *so, struct mbuf *a | @@ -951,27 +952,27 @@ sosend(struct socket *so, struct mbuf *a | |||
951 | goto release; | 952 | goto release; | |
952 | } | 953 | } | |
953 | } | 954 | } | |
954 | space = sbspace(&so->so_snd); | 955 | space = sbspace(&so->so_snd); | |
955 | if (flags & MSG_OOB) | 956 | if (flags & MSG_OOB) | |
956 | space += 1024; | 957 | space += 1024; | |
957 | if ((atomic && resid > so->so_snd.sb_hiwat) || | 958 | if ((atomic && resid > so->so_snd.sb_hiwat) || | |
958 | clen > so->so_snd.sb_hiwat) { | 959 | clen > so->so_snd.sb_hiwat) { | |
959 | error = EMSGSIZE; | 960 | error = EMSGSIZE; | |
960 | goto release; | 961 | goto release; | |
961 | } | 962 | } | |
962 | if (space < resid + clen && | 963 | if (space < resid + clen && | |
963 | (atomic || space < so->so_snd.sb_lowat || space < clen)) { | 964 | (atomic || space < so->so_snd.sb_lowat || space < clen)) { | |
964 | if (so->so_nbio) { | 965 | if ((so->so_state & SS_NBIO) || (flags & MSG_NBIO)) { | |
965 | error = EWOULDBLOCK; | 966 | error = EWOULDBLOCK; | |
966 | goto release; | 967 | goto release; | |
967 | } | 968 | } | |
968 | sbunlock(&so->so_snd); | 969 | sbunlock(&so->so_snd); | |
969 | if (wakeup_state & SS_RESTARTSYS) { | 970 | if (wakeup_state & SS_RESTARTSYS) { | |
970 | error = ERESTART; | 971 | error = ERESTART; | |
971 | goto out; | 972 | goto out; | |
972 | } | 973 | } | |
973 | error = sbwait(&so->so_snd); | 974 | error = sbwait(&so->so_snd); | |
974 | if (error) | 975 | if (error) | |
975 | goto out; | 976 | goto out; | |
976 | wakeup_state = so->so_state; | 977 | wakeup_state = so->so_state; | |
977 | goto restart; | 978 | goto restart; | |
@@ -1247,27 +1248,28 @@ soreceive(struct socket *so, struct mbuf | @@ -1247,27 +1248,28 @@ soreceive(struct socket *so, struct mbuf | |||
1247 | } | 1248 | } | |
1248 | for (; m != NULL; m = m->m_next) | 1249 | for (; m != NULL; m = m->m_next) | |
1249 | if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) { | 1250 | if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) { | |
1250 | m = so->so_rcv.sb_mb; | 1251 | m = so->so_rcv.sb_mb; | |
1251 | goto dontblock; | 1252 | goto dontblock; | |
1252 | } | 1253 | } | |
1253 | if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 && | 1254 | if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 && | |
1254 | (so->so_proto->pr_flags & PR_CONNREQUIRED)) { | 1255 | (so->so_proto->pr_flags & PR_CONNREQUIRED)) { | |
1255 | error = ENOTCONN; | 1256 | error = ENOTCONN; | |
1256 | goto release; | 1257 | goto release; | |
1257 | } | 1258 | } | |
1258 | if (uio->uio_resid == 0) | 1259 | if (uio->uio_resid == 0) | |
1259 | goto release; | 1260 | goto release; | |
1260 | if (so->so_nbio || (flags & MSG_DONTWAIT)) { | 1261 | if ((so->so_state & SS_NBIO) || | |
1262 | (flags & (MSG_DONTWAIT|MSG_NBIO))) { | |||
1261 | error = EWOULDBLOCK; | 1263 | error = EWOULDBLOCK; | |
1262 | goto release; | 1264 | goto release; | |
1263 | } | 1265 | } | |
1264 | SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1"); | 1266 | SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1"); | |
1265 | SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1"); | 1267 | SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1"); | |
1266 | sbunlock(&so->so_rcv); | 1268 | sbunlock(&so->so_rcv); | |
1267 | if (wakeup_state & SS_RESTARTSYS) | 1269 | if (wakeup_state & SS_RESTARTSYS) | |
1268 | error = ERESTART; | 1270 | error = ERESTART; | |
1269 | else | 1271 | else | |
1270 | error = sbwait(&so->so_rcv); | 1272 | error = sbwait(&so->so_rcv); | |
1271 | if (error != 0) { | 1273 | if (error != 0) { | |
1272 | sounlock(so); | 1274 | sounlock(so); | |
1273 | splx(s); | 1275 | splx(s); |
--- src/sys/kern/uipc_socket2.c 2011/08/31 18:31:03 1.109
+++ src/sys/kern/uipc_socket2.c 2011/12/20 23:56:28 1.110
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uipc_socket2.c,v 1.109 2011/08/31 18:31:03 plunky Exp $ */ | 1 | /* $NetBSD: uipc_socket2.c,v 1.110 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | 55 | * SUCH DAMAGE. | |
56 | * | 56 | * | |
57 | * @(#)uipc_socket2.c 8.2 (Berkeley) 2/14/95 | 57 | * @(#)uipc_socket2.c 8.2 (Berkeley) 2/14/95 | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.109 2011/08/31 18:31:03 plunky Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.110 2011/12/20 23:56:28 christos Exp $"); | |
62 | 62 | |||
63 | #include "opt_mbuftrace.h" | 63 | #include "opt_mbuftrace.h" | |
64 | #include "opt_sb_max.h" | 64 | #include "opt_sb_max.h" | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/systm.h> | 67 | #include <sys/systm.h> | |
68 | #include <sys/proc.h> | 68 | #include <sys/proc.h> | |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> | |
70 | #include <sys/buf.h> | 70 | #include <sys/buf.h> | |
71 | #include <sys/mbuf.h> | 71 | #include <sys/mbuf.h> | |
72 | #include <sys/protosw.h> | 72 | #include <sys/protosw.h> | |
73 | #include <sys/domain.h> | 73 | #include <sys/domain.h> | |
74 | #include <sys/poll.h> | 74 | #include <sys/poll.h> | |
@@ -255,27 +255,26 @@ sonewconn(struct socket *head, int conns | @@ -255,27 +255,26 @@ sonewconn(struct socket *head, int conns | |||
255 | connstatus = 0; | 255 | connstatus = 0; | |
256 | soqueue = connstatus ? 1 : 0; | 256 | soqueue = connstatus ? 1 : 0; | |
257 | if (head->so_qlen + head->so_q0len > 3 * head->so_qlimit / 2) | 257 | if (head->so_qlen + head->so_q0len > 3 * head->so_qlimit / 2) | |
258 | return NULL; | 258 | return NULL; | |
259 | so = soget(false); | 259 | so = soget(false); | |
260 | if (so == NULL) | 260 | if (so == NULL) | |
261 | return NULL; | 261 | return NULL; | |
262 | mutex_obj_hold(head->so_lock); | 262 | mutex_obj_hold(head->so_lock); | |
263 | so->so_lock = head->so_lock; | 263 | so->so_lock = head->so_lock; | |
264 | so->so_type = head->so_type; | 264 | so->so_type = head->so_type; | |
265 | so->so_options = head->so_options &~ SO_ACCEPTCONN; | 265 | so->so_options = head->so_options &~ SO_ACCEPTCONN; | |
266 | so->so_linger = head->so_linger; | 266 | so->so_linger = head->so_linger; | |
267 | so->so_state = head->so_state | SS_NOFDREF; | 267 | so->so_state = head->so_state | SS_NOFDREF; | |
268 | so->so_nbio = head->so_nbio; | |||
269 | so->so_proto = head->so_proto; | 268 | so->so_proto = head->so_proto; | |
270 | so->so_timeo = head->so_timeo; | 269 | so->so_timeo = head->so_timeo; | |
271 | so->so_pgid = head->so_pgid; | 270 | so->so_pgid = head->so_pgid; | |
272 | so->so_send = head->so_send; | 271 | so->so_send = head->so_send; | |
273 | so->so_receive = head->so_receive; | 272 | so->so_receive = head->so_receive; | |
274 | so->so_uidinfo = head->so_uidinfo; | 273 | so->so_uidinfo = head->so_uidinfo; | |
275 | so->so_cpid = head->so_cpid; | 274 | so->so_cpid = head->so_cpid; | |
276 | #ifdef MBUFTRACE | 275 | #ifdef MBUFTRACE | |
277 | so->so_mowner = head->so_mowner; | 276 | so->so_mowner = head->so_mowner; | |
278 | so->so_rcv.sb_mowner = head->so_rcv.sb_mowner; | 277 | so->so_rcv.sb_mowner = head->so_rcv.sb_mowner; | |
279 | so->so_snd.sb_mowner = head->so_snd.sb_mowner; | 278 | so->so_snd.sb_mowner = head->so_snd.sb_mowner; | |
280 | #endif | 279 | #endif | |
281 | if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) != 0) | 280 | if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) != 0) |
--- src/sys/kern/uipc_syscalls.c 2011/11/04 02:13:08 1.148
+++ src/sys/kern/uipc_syscalls.c 2011/12/20 23:56:28 1.149
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uipc_syscalls.c,v 1.148 2011/11/04 02:13:08 christos Exp $ */ | 1 | /* $NetBSD: uipc_syscalls.c,v 1.149 2011/12/20 23:56:28 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
58 | * SUCH DAMAGE. | 58 | * SUCH DAMAGE. | |
59 | * | 59 | * | |
60 | * @(#)uipc_syscalls.c 8.6 (Berkeley) 2/14/95 | 60 | * @(#)uipc_syscalls.c 8.6 (Berkeley) 2/14/95 | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.148 2011/11/04 02:13:08 christos Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.149 2011/12/20 23:56:28 christos Exp $"); | |
65 | 65 | |||
66 | #include "opt_pipe.h" | 66 | #include "opt_pipe.h" | |
67 | 67 | |||
68 | #include <sys/param.h> | 68 | #include <sys/param.h> | |
69 | #include <sys/systm.h> | 69 | #include <sys/systm.h> | |
70 | #include <sys/filedesc.h> | 70 | #include <sys/filedesc.h> | |
71 | #include <sys/proc.h> | 71 | #include <sys/proc.h> | |
72 | #include <sys/file.h> | 72 | #include <sys/file.h> | |
73 | #include <sys/buf.h> | 73 | #include <sys/buf.h> | |
74 | #define MBUFTYPES | 74 | #define MBUFTYPES | |
75 | #include <sys/mbuf.h> | 75 | #include <sys/mbuf.h> | |
76 | #include <sys/protosw.h> | 76 | #include <sys/protosw.h> | |
77 | #include <sys/socket.h> | 77 | #include <sys/socket.h> | |
@@ -188,27 +188,27 @@ do_sys_accept(struct lwp *l, int sock, s | @@ -188,27 +188,27 @@ do_sys_accept(struct lwp *l, int sock, s | |||
188 | solock(so); | 188 | solock(so); | |
189 | 189 | |||
190 | if (__predict_false(mask)) | 190 | if (__predict_false(mask)) | |
191 | sigsuspendsetup(l, mask); | 191 | sigsuspendsetup(l, mask); | |
192 | 192 | |||
193 | if (!(so->so_proto->pr_flags & PR_LISTEN)) { | 193 | if (!(so->so_proto->pr_flags & PR_LISTEN)) { | |
194 | error = EOPNOTSUPP; | 194 | error = EOPNOTSUPP; | |
195 | goto bad; | 195 | goto bad; | |
196 | } | 196 | } | |
197 | if ((so->so_options & SO_ACCEPTCONN) == 0) { | 197 | if ((so->so_options & SO_ACCEPTCONN) == 0) { | |
198 | error = EINVAL; | 198 | error = EINVAL; | |
199 | goto bad; | 199 | goto bad; | |
200 | } | 200 | } | |
201 | if (so->so_nbio && so->so_qlen == 0) { | 201 | if ((so->so_state & SS_NBIO) && so->so_qlen == 0) { | |
202 | error = EWOULDBLOCK; | 202 | error = EWOULDBLOCK; | |
203 | goto bad; | 203 | goto bad; | |
204 | } | 204 | } | |
205 | while (so->so_qlen == 0 && so->so_error == 0) { | 205 | while (so->so_qlen == 0 && so->so_error == 0) { | |
206 | if (so->so_state & SS_CANTRCVMORE) { | 206 | if (so->so_state & SS_CANTRCVMORE) { | |
207 | so->so_error = ECONNABORTED; | 207 | so->so_error = ECONNABORTED; | |
208 | break; | 208 | break; | |
209 | } | 209 | } | |
210 | if (wakeup_state & SS_RESTARTSYS) { | 210 | if (wakeup_state & SS_RESTARTSYS) { | |
211 | error = ERESTART; | 211 | error = ERESTART; | |
212 | goto bad; | 212 | goto bad; | |
213 | } | 213 | } | |
214 | error = sowait(so, true, 0); | 214 | error = sowait(so, true, 0); | |
@@ -357,27 +357,27 @@ do_sys_connect(struct lwp *l, int fd, st | @@ -357,27 +357,27 @@ do_sys_connect(struct lwp *l, int fd, st | |||
357 | m_freem(nam); | 357 | m_freem(nam); | |
358 | return (error); | 358 | return (error); | |
359 | } | 359 | } | |
360 | solock(so); | 360 | solock(so); | |
361 | MCLAIM(nam, so->so_mowner); | 361 | MCLAIM(nam, so->so_mowner); | |
362 | if ((so->so_state & SS_ISCONNECTING) != 0) { | 362 | if ((so->so_state & SS_ISCONNECTING) != 0) { | |
363 | error = EALREADY; | 363 | error = EALREADY; | |
364 | goto out; | 364 | goto out; | |
365 | } | 365 | } | |
366 | 366 | |||
367 | error = soconnect(so, nam, l); | 367 | error = soconnect(so, nam, l); | |
368 | if (error) | 368 | if (error) | |
369 | goto bad; | 369 | goto bad; | |
370 | if (so->so_nbio && (so->so_state & SS_ISCONNECTING) != 0) { | 370 | if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING) != 0) { | |
371 | error = EINPROGRESS; | 371 | error = EINPROGRESS; | |
372 | goto out; | 372 | goto out; | |
373 | } | 373 | } | |
374 | while ((so->so_state & SS_ISCONNECTING) != 0 && so->so_error == 0) { | 374 | while ((so->so_state & SS_ISCONNECTING) != 0 && so->so_error == 0) { | |
375 | error = sowait(so, true, 0); | 375 | error = sowait(so, true, 0); | |
376 | if (__predict_false((so->so_state & SS_ISABORTING) != 0)) { | 376 | if (__predict_false((so->so_state & SS_ISABORTING) != 0)) { | |
377 | error = EPIPE; | 377 | error = EPIPE; | |
378 | interrupted = 1; | 378 | interrupted = 1; | |
379 | break; | 379 | break; | |
380 | } | 380 | } | |
381 | if (error) { | 381 | if (error) { | |
382 | if (error == EINTR || error == ERESTART) | 382 | if (error == EINTR || error == ERESTART) | |
383 | interrupted = 1; | 383 | interrupted = 1; |
--- src/sys/miscfs/fifofs/fifo_vnops.c 2011/08/31 18:31:03 1.70
+++ src/sys/miscfs/fifofs/fifo_vnops.c 2011/12/20 23:56:29 1.71
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: fifo_vnops.c,v 1.70 2011/08/31 18:31:03 plunky Exp $ */ | 1 | /* $NetBSD: fifo_vnops.c,v 1.71 2011/12/20 23:56:29 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | 55 | * SUCH DAMAGE. | |
56 | * | 56 | * | |
57 | * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 | 57 | * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.70 2011/08/31 18:31:03 plunky Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.71 2011/12/20 23:56:29 christos Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/systm.h> | 64 | #include <sys/systm.h> | |
65 | #include <sys/proc.h> | 65 | #include <sys/proc.h> | |
66 | #include <sys/time.h> | 66 | #include <sys/time.h> | |
67 | #include <sys/namei.h> | 67 | #include <sys/namei.h> | |
68 | #include <sys/vnode.h> | 68 | #include <sys/vnode.h> | |
69 | #include <sys/socket.h> | 69 | #include <sys/socket.h> | |
70 | #include <sys/protosw.h> | 70 | #include <sys/protosw.h> | |
71 | #include <sys/socketvar.h> | 71 | #include <sys/socketvar.h> | |
72 | #include <sys/stat.h> | 72 | #include <sys/stat.h> | |
73 | #include <sys/ioctl.h> | 73 | #include <sys/ioctl.h> | |
74 | #include <sys/file.h> | 74 | #include <sys/file.h> | |
@@ -233,88 +233,79 @@ fifo_open(void *v) | @@ -233,88 +233,79 @@ fifo_open(void *v) | |||
233 | */ | 233 | */ | |
234 | /* ARGSUSED */ | 234 | /* ARGSUSED */ | |
235 | static int | 235 | static int | |
236 | fifo_read(void *v) | 236 | fifo_read(void *v) | |
237 | { | 237 | { | |
238 | struct vop_read_args /* { | 238 | struct vop_read_args /* { | |
239 | struct vnode *a_vp; | 239 | struct vnode *a_vp; | |
240 | struct uio *a_uio; | 240 | struct uio *a_uio; | |
241 | int a_ioflag; | 241 | int a_ioflag; | |
242 | kauth_cred_t a_cred; | 242 | kauth_cred_t a_cred; | |
243 | } */ *ap = v; | 243 | } */ *ap = v; | |
244 | struct uio *uio; | 244 | struct uio *uio; | |
245 | struct socket *rso; | 245 | struct socket *rso; | |
246 | int error; | 246 | int error, sflags; | |
247 | size_t startresid; | 247 | size_t startresid; | |
248 | 248 | |||
249 | uio = ap->a_uio; | 249 | uio = ap->a_uio; | |
250 | rso = ap->a_vp->v_fifoinfo->fi_readsock; | 250 | rso = ap->a_vp->v_fifoinfo->fi_readsock; | |
251 | #ifdef DIAGNOSTIC | 251 | #ifdef DIAGNOSTIC | |
252 | if (uio->uio_rw != UIO_READ) | 252 | if (uio->uio_rw != UIO_READ) | |
253 | panic("fifo_read mode"); | 253 | panic("fifo_read mode"); | |
254 | #endif | 254 | #endif | |
255 | if (uio->uio_resid == 0) | 255 | if (uio->uio_resid == 0) | |
256 | return (0); | 256 | return (0); | |
257 | startresid = uio->uio_resid; | 257 | startresid = uio->uio_resid; | |
258 | VOP_UNLOCK(ap->a_vp); | 258 | VOP_UNLOCK(ap->a_vp); | |
259 | if (ap->a_ioflag & IO_NDELAY) { | 259 | sflags = (ap->a_ioflag & IO_NDELAY) ? MSG_NBIO : 0; | |
260 | /* XXX Bogus, affects other threads. */ | 260 | error = (*rso->so_receive)(rso, NULL, uio, NULL, NULL, &sflags); | |
261 | rso->so_nbio = 1; | |||
262 | } | |||
263 | error = (*rso->so_receive)(rso, NULL, uio, NULL, NULL, NULL); | |||
264 | /* | 261 | /* | |
265 | * Clear EOF indication after first such return. | 262 | * Clear EOF indication after first such return. | |
266 | */ | 263 | */ | |
267 | if (uio->uio_resid == startresid) | 264 | if (error != EINTR && uio->uio_resid == startresid) | |
268 | rso->so_state &= ~SS_CANTRCVMORE; | 265 | rso->so_state &= ~SS_CANTRCVMORE; | |
269 | if (ap->a_ioflag & IO_NDELAY) { | 266 | if (ap->a_ioflag & IO_NDELAY) { | |
270 | rso->so_nbio = 0; | |||
271 | if (error == EWOULDBLOCK && | 267 | if (error == EWOULDBLOCK && | |
272 | ap->a_vp->v_fifoinfo->fi_writers == 0) | 268 | ap->a_vp->v_fifoinfo->fi_writers == 0) | |
273 | error = 0; | 269 | error = 0; | |
274 | } | 270 | } | |
275 | vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); | 271 | vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); | |
276 | return (error); | 272 | return (error); | |
277 | } | 273 | } | |
278 | 274 | |||
279 | /* | 275 | /* | |
280 | * Vnode op for write | 276 | * Vnode op for write | |
281 | */ | 277 | */ | |
282 | /* ARGSUSED */ | 278 | /* ARGSUSED */ | |
283 | static int | 279 | static int | |
284 | fifo_write(void *v) | 280 | fifo_write(void *v) | |
285 | { | 281 | { | |
286 | struct vop_write_args /* { | 282 | struct vop_write_args /* { | |
287 | struct vnode *a_vp; | 283 | struct vnode *a_vp; | |
288 | struct uio *a_uio; | 284 | struct uio *a_uio; | |
289 | int a_ioflag; | 285 | int a_ioflag; | |
290 | kauth_cred_t a_cred; | 286 | kauth_cred_t a_cred; | |
291 | } */ *ap = v; | 287 | } */ *ap = v; | |
292 | struct socket *wso; | 288 | struct socket *wso; | |
293 | int error; | 289 | int error, sflags; | |
294 | 290 | |||
295 | wso = ap->a_vp->v_fifoinfo->fi_writesock; | 291 | wso = ap->a_vp->v_fifoinfo->fi_writesock; | |
296 | #ifdef DIAGNOSTIC | 292 | #ifdef DIAGNOSTIC | |
297 | if (ap->a_uio->uio_rw != UIO_WRITE) | 293 | if (ap->a_uio->uio_rw != UIO_WRITE) | |
298 | panic("fifo_write mode"); | 294 | panic("fifo_write mode"); | |
299 | #endif | 295 | #endif | |
300 | VOP_UNLOCK(ap->a_vp); | 296 | VOP_UNLOCK(ap->a_vp); | |
301 | if (ap->a_ioflag & IO_NDELAY) { | 297 | sflags = (ap->a_ioflag & IO_NDELAY) ? MSG_NBIO : 0; | |
302 | /* XXX Bogus, affects other threads. */ | 298 | error = (*wso->so_send)(wso, NULL, ap->a_uio, 0, NULL, sflags, curlwp); | |
303 | wso->so_nbio = 1; | |||
304 | } | |||
305 | error = (*wso->so_send)(wso, NULL, ap->a_uio, 0, NULL, 0, curlwp); | |||
306 | if (ap->a_ioflag & IO_NDELAY) | |||
307 | wso->so_nbio = 0; | |||
308 | vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); | 299 | vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); | |
309 | return (error); | 300 | return (error); | |
310 | } | 301 | } | |
311 | 302 | |||
312 | /* | 303 | /* | |
313 | * Device ioctl operation. | 304 | * Device ioctl operation. | |
314 | */ | 305 | */ | |
315 | /* ARGSUSED */ | 306 | /* ARGSUSED */ | |
316 | static int | 307 | static int | |
317 | fifo_ioctl(void *v) | 308 | fifo_ioctl(void *v) | |
318 | { | 309 | { | |
319 | struct vop_ioctl_args /* { | 310 | struct vop_ioctl_args /* { | |
320 | struct vnode *a_vp; | 311 | struct vnode *a_vp; |
--- src/sys/netiso/Attic/tp_usrreq.c 2009/03/18 22:08:57 1.40
+++ src/sys/netiso/Attic/tp_usrreq.c 2011/12/20 23:56:29 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tp_usrreq.c,v 1.40 2009/03/18 22:08:57 he Exp $ */ | 1 | /* $NetBSD: tp_usrreq.c,v 1.41 2011/12/20 23:56:29 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1991, 1993 | 4 | * Copyright (c) 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -55,27 +55,27 @@ SOFTWARE. | @@ -55,27 +55,27 @@ SOFTWARE. | |||
55 | ******************************************************************/ | 55 | ******************************************************************/ | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison | 58 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison | |
59 | */ | 59 | */ | |
60 | /* | 60 | /* | |
61 | * tp_usrreq(), the fellow that gets called from most of the socket code. | 61 | * tp_usrreq(), the fellow that gets called from most of the socket code. | |
62 | * Pretty straighforward. THe only really awful stuff here is the OOB | 62 | * Pretty straighforward. THe only really awful stuff here is the OOB | |
63 | * processing, which is done wholly here. tp_rcvoob() and tp_sendoob() are | 63 | * processing, which is done wholly here. tp_rcvoob() and tp_sendoob() are | |
64 | * contained here and called by tp_usrreq(). | 64 | * contained here and called by tp_usrreq(). | |
65 | */ | 65 | */ | |
66 | 66 | |||
67 | #include <sys/cdefs.h> | 67 | #include <sys/cdefs.h> | |
68 | __KERNEL_RCSID(0, "$NetBSD: tp_usrreq.c,v 1.40 2009/03/18 22:08:57 he Exp $"); | 68 | __KERNEL_RCSID(0, "$NetBSD: tp_usrreq.c,v 1.41 2011/12/20 23:56:29 christos Exp $"); | |
69 | 69 | |||
70 | #include <sys/param.h> | 70 | #include <sys/param.h> | |
71 | #include <sys/systm.h> | 71 | #include <sys/systm.h> | |
72 | #include <sys/mbuf.h> | 72 | #include <sys/mbuf.h> | |
73 | #include <sys/socket.h> | 73 | #include <sys/socket.h> | |
74 | #include <sys/socketvar.h> | 74 | #include <sys/socketvar.h> | |
75 | #include <sys/domain.h> | 75 | #include <sys/domain.h> | |
76 | #include <sys/protosw.h> | 76 | #include <sys/protosw.h> | |
77 | #include <sys/errno.h> | 77 | #include <sys/errno.h> | |
78 | #include <sys/time.h> | 78 | #include <sys/time.h> | |
79 | #include <sys/proc.h> | 79 | #include <sys/proc.h> | |
80 | 80 | |||
81 | #include <netiso/tp_param.h> | 81 | #include <netiso/tp_param.h> | |
@@ -202,27 +202,27 @@ restart: | @@ -202,27 +202,27 @@ restart: | |||
202 | 202 | |||
203 | sblock(sb, M_WAITOK); | 203 | sblock(sb, M_WAITOK); | |
204 | for (nn = &sb->sb_mb; (n = *nn) != NULL; nn = &n->m_nextpkt) | 204 | for (nn = &sb->sb_mb; (n = *nn) != NULL; nn = &n->m_nextpkt) | |
205 | if (n->m_type == MT_OOBDATA) | 205 | if (n->m_type == MT_OOBDATA) | |
206 | break; | 206 | break; | |
207 | 207 | |||
208 | if (n == 0) { | 208 | if (n == 0) { | |
209 | #ifdef ARGO_DEBUG | 209 | #ifdef ARGO_DEBUG | |
210 | if (argo_debug[D_XPD]) { | 210 | if (argo_debug[D_XPD]) { | |
211 | printf("RCVOOB: empty queue!\n"); | 211 | printf("RCVOOB: empty queue!\n"); | |
212 | } | 212 | } | |
213 | #endif | 213 | #endif | |
214 | sbunlock(sb); | 214 | sbunlock(sb); | |
215 | if (so->so_nbio) { | 215 | if (so->so_state & SS_NBIO) { | |
216 | return EWOULDBLOCK; | 216 | return EWOULDBLOCK; | |
217 | } | 217 | } | |
218 | sbwait(sb); | 218 | sbwait(sb); | |
219 | goto restart; | 219 | goto restart; | |
220 | } | 220 | } | |
221 | m->m_len = 0; | 221 | m->m_len = 0; | |
222 | 222 | |||
223 | /* Assuming at most one xpd tpdu is in the buffer at once */ | 223 | /* Assuming at most one xpd tpdu is in the buffer at once */ | |
224 | while (n != NULL) { | 224 | while (n != NULL) { | |
225 | m->m_len += n->m_len; | 225 | m->m_len += n->m_len; | |
226 | memcpy(mtod(m, void *), mtod(n, void *), (unsigned) n->m_len); | 226 | memcpy(mtod(m, void *), mtod(n, void *), (unsigned) n->m_len); | |
227 | m->m_data += n->m_len; /* so mtod() in bcopy() above gives | 227 | m->m_data += n->m_len; /* so mtod() in bcopy() above gives | |
228 | * right addr */ | 228 | * right addr */ | |
@@ -296,27 +296,27 @@ tp_sendoob(struct tp_pcb *tpcb, struct s | @@ -296,27 +296,27 @@ tp_sendoob(struct tp_pcb *tpcb, struct s | |||
296 | if (xdata) | 296 | if (xdata) | |
297 | printf("xdata len 0x%x\n", xdata->m_len); | 297 | printf("xdata len 0x%x\n", xdata->m_len); | |
298 | } | 298 | } | |
299 | #endif | 299 | #endif | |
300 | /* | 300 | /* | |
301 | * DO NOT LOCK the Xsnd buffer!!!! You can have at MOST one socket | 301 | * DO NOT LOCK the Xsnd buffer!!!! You can have at MOST one socket | |
302 | * buf locked at any time!!! (otherwise you might sleep() in sblock() | 302 | * buf locked at any time!!! (otherwise you might sleep() in sblock() | |
303 | * w/ a signal pending and cause the system call to be aborted w/ a | 303 | * w/ a signal pending and cause the system call to be aborted w/ a | |
304 | * locked socketbuf, which is a problem. So the so_snd buffer lock | 304 | * locked socketbuf, which is a problem. So the so_snd buffer lock | |
305 | * (done in sosend()) serves as the lock for Xpd. | 305 | * (done in sosend()) serves as the lock for Xpd. | |
306 | */ | 306 | */ | |
307 | if (sb->sb_mb) { /* Anything already in eXpedited data | 307 | if (sb->sb_mb) { /* Anything already in eXpedited data | |
308 | * sockbuf? */ | 308 | * sockbuf? */ | |
309 | if (so->so_nbio) { | 309 | if (so->so_state & SS_NBIO) { | |
310 | return EWOULDBLOCK; | 310 | return EWOULDBLOCK; | |
311 | } | 311 | } | |
312 | while (sb->sb_mb) { | 312 | while (sb->sb_mb) { | |
313 | sbunlock(&so->so_snd); /* already locked by sosend */ | 313 | sbunlock(&so->so_snd); /* already locked by sosend */ | |
314 | sbwait(&so->so_snd); | 314 | sbwait(&so->so_snd); | |
315 | sblock(&so->so_snd, M_WAITOK); /* sosend will unlock on | 315 | sblock(&so->so_snd, M_WAITOK); /* sosend will unlock on | |
316 | * return */ | 316 | * return */ | |
317 | } | 317 | } | |
318 | } | 318 | } | |
319 | if (xdata == (struct mbuf *) 0) { | 319 | if (xdata == (struct mbuf *) 0) { | |
320 | /* empty xpd packet */ | 320 | /* empty xpd packet */ | |
321 | xdata = m_gethdr(M_WAIT, MT_OOBDATA); | 321 | xdata = m_gethdr(M_WAIT, MT_OOBDATA); | |
322 | xdata->m_len = 0; | 322 | xdata->m_len = 0; |
--- src/sys/sys/socket.h 2011/06/26 16:43:12 1.100
+++ src/sys/sys/socket.h 2011/12/20 23:56:29 1.101
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: socket.h,v 1.100 2011/06/26 16:43:12 christos Exp $ */ | 1 | /* $NetBSD: socket.h,v 1.101 2011/12/20 23:56:29 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -482,26 +482,27 @@ struct msghdr { | @@ -482,26 +482,27 @@ struct msghdr { | |||
482 | #define MSG_OOB 0x0001 /* process out-of-band data */ | 482 | #define MSG_OOB 0x0001 /* process out-of-band data */ | |
483 | #define MSG_PEEK 0x0002 /* peek at incoming message */ | 483 | #define MSG_PEEK 0x0002 /* peek at incoming message */ | |
484 | #define MSG_DONTROUTE 0x0004 /* send without using routing tables */ | 484 | #define MSG_DONTROUTE 0x0004 /* send without using routing tables */ | |
485 | #define MSG_EOR 0x0008 /* data completes record */ | 485 | #define MSG_EOR 0x0008 /* data completes record */ | |
486 | #define MSG_TRUNC 0x0010 /* data discarded before delivery */ | 486 | #define MSG_TRUNC 0x0010 /* data discarded before delivery */ | |
487 | #define MSG_CTRUNC 0x0020 /* control data lost before delivery */ | 487 | #define MSG_CTRUNC 0x0020 /* control data lost before delivery */ | |
488 | #define MSG_WAITALL 0x0040 /* wait for full request or error */ | 488 | #define MSG_WAITALL 0x0040 /* wait for full request or error */ | |
489 | #define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */ | 489 | #define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */ | |
490 | #define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */ | 490 | #define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */ | |
491 | #define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */ | 491 | #define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */ | |
492 | #define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */ | 492 | #define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */ | |
493 | #if defined(_NETBSD_SOURCE) | 493 | #if defined(_NETBSD_SOURCE) | |
494 | #define MSG_CMSG_CLOEXEC 0x0800 /* close on exec receiving fd */ | 494 | #define MSG_CMSG_CLOEXEC 0x0800 /* close on exec receiving fd */ | |
495 | #define MSG_NBIO 0x1000 /* use non-blocking I/O */ | |||
495 | #endif | 496 | #endif | |
496 | 497 | |||
497 | /* Extra flags used internally only */ | 498 | /* Extra flags used internally only */ | |
498 | #define MSG_USERFLAGS 0x0ffffff | 499 | #define MSG_USERFLAGS 0x0ffffff | |
499 | #define MSG_NAMEMBUF 0x1000000 /* msg_name is an mbuf */ | 500 | #define MSG_NAMEMBUF 0x1000000 /* msg_name is an mbuf */ | |
500 | #define MSG_CONTROLMBUF 0x2000000 /* msg_control is an mbuf */ | 501 | #define MSG_CONTROLMBUF 0x2000000 /* msg_control is an mbuf */ | |
501 | #define MSG_IOVUSRSPACE 0x4000000 /* msg_iov is in user space */ | 502 | #define MSG_IOVUSRSPACE 0x4000000 /* msg_iov is in user space */ | |
502 | #define MSG_LENUSRSPACE 0x8000000 /* address length is in user space */ | 503 | #define MSG_LENUSRSPACE 0x8000000 /* address length is in user space */ | |
503 | 504 | |||
504 | /* | 505 | /* | |
505 | * Header for ancillary data objects in msg_control buffer. | 506 | * Header for ancillary data objects in msg_control buffer. | |
506 | * Used for additional information with/about a datagram | 507 | * Used for additional information with/about a datagram | |
507 | * not expressible by flags. The format is a sequence | 508 | * not expressible by flags. The format is a sequence |
--- src/sys/sys/socketvar.h 2011/07/02 17:53:51 1.126
+++ src/sys/sys/socketvar.h 2011/12/20 23:56:29 1.127
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: socketvar.h,v 1.126 2011/07/02 17:53:51 bouyer Exp $ */ | 1 | /* $NetBSD: socketvar.h,v 1.127 2011/12/20 23:56:29 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -118,27 +118,26 @@ struct sockbuf { | @@ -118,27 +118,26 @@ struct sockbuf { | |||
118 | /* | 118 | /* | |
119 | * Kernel structure per socket. | 119 | * Kernel structure per socket. | |
120 | * Contains send and receive buffer queues, | 120 | * Contains send and receive buffer queues, | |
121 | * handle on protocol and pointer to protocol | 121 | * handle on protocol and pointer to protocol | |
122 | * private data and error information. | 122 | * private data and error information. | |
123 | */ | 123 | */ | |
124 | struct socket { | 124 | struct socket { | |
125 | kmutex_t * volatile so_lock; /* pointer to lock on structure */ | 125 | kmutex_t * volatile so_lock; /* pointer to lock on structure */ | |
126 | kcondvar_t so_cv; /* notifier */ | 126 | kcondvar_t so_cv; /* notifier */ | |
127 | short so_type; /* generic type, see socket.h */ | 127 | short so_type; /* generic type, see socket.h */ | |
128 | short so_options; /* from socket call, see socket.h */ | 128 | short so_options; /* from socket call, see socket.h */ | |
129 | u_short so_linger; /* time to linger while closing */ | 129 | u_short so_linger; /* time to linger while closing */ | |
130 | short so_state; /* internal state flags SS_*, below */ | 130 | short so_state; /* internal state flags SS_*, below */ | |
131 | int so_nbio; /* non-blocking I/O enabled */ | |||
132 | void *so_pcb; /* protocol control block */ | 131 | void *so_pcb; /* protocol control block */ | |
133 | const struct protosw *so_proto; /* protocol handle */ | 132 | const struct protosw *so_proto; /* protocol handle */ | |
134 | /* | 133 | /* | |
135 | * Variables for connection queueing. | 134 | * Variables for connection queueing. | |
136 | * Socket where accepts occur is so_head in all subsidiary sockets. | 135 | * Socket where accepts occur is so_head in all subsidiary sockets. | |
137 | * If so_head is 0, socket is not related to an accept. | 136 | * If so_head is 0, socket is not related to an accept. | |
138 | * For head socket so_q0 queues partially completed connections, | 137 | * For head socket so_q0 queues partially completed connections, | |
139 | * while so_q is a queue of connections ready to be accepted. | 138 | * while so_q is a queue of connections ready to be accepted. | |
140 | * If a connection is aborted and it has so_head set, then | 139 | * If a connection is aborted and it has so_head set, then | |
141 | * it has to be pulled out of either so_q0 or so_q. | 140 | * it has to be pulled out of either so_q0 or so_q. | |
142 | * We allow connections to queue up based on current queue lengths | 141 | * We allow connections to queue up based on current queue lengths | |
143 | * and limit on number of queued connections for this socket. | 142 | * and limit on number of queued connections for this socket. | |
144 | */ | 143 | */ | |
@@ -200,26 +199,27 @@ do { \ | @@ -200,26 +199,27 @@ do { \ | |||
200 | #define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */ | 199 | #define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */ | |
201 | #define SS_RCVATMARK 0x040 /* at mark on input */ | 200 | #define SS_RCVATMARK 0x040 /* at mark on input */ | |
202 | #define SS_ISABORTING 0x080 /* aborting fd references - close() */ | 201 | #define SS_ISABORTING 0x080 /* aborting fd references - close() */ | |
203 | #define SS_RESTARTSYS 0x100 /* restart blocked system calls */ | 202 | #define SS_RESTARTSYS 0x100 /* restart blocked system calls */ | |
204 | #define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ | 203 | #define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ | |
205 | 204 | |||
206 | #define SS_ASYNC 0x100 /* async i/o notify */ | 205 | #define SS_ASYNC 0x100 /* async i/o notify */ | |
207 | #define SS_ISCONFIRMING 0x200 /* deciding to accept connection req */ | 206 | #define SS_ISCONFIRMING 0x200 /* deciding to accept connection req */ | |
208 | #define SS_MORETOCOME 0x400 /* | 207 | #define SS_MORETOCOME 0x400 /* | |
209 | * hint from sosend to lower layer; | 208 | * hint from sosend to lower layer; | |
210 | * more data coming | 209 | * more data coming | |
211 | */ | 210 | */ | |
212 | #define SS_ISAPIPE 0x1000 /* socket is implementing a pipe */ | 211 | #define SS_ISAPIPE 0x1000 /* socket is implementing a pipe */ | |
212 | #define SS_NBIO 0x2000 /* socket is in non blocking I/O */ | |||
213 | 213 | |||
214 | #ifdef _KERNEL | 214 | #ifdef _KERNEL | |
215 | 215 | |||
216 | struct accept_filter { | 216 | struct accept_filter { | |
217 | char accf_name[16]; | 217 | char accf_name[16]; | |
218 | void (*accf_callback) | 218 | void (*accf_callback) | |
219 | (struct socket *, void *, int, int); | 219 | (struct socket *, void *, int, int); | |
220 | void * (*accf_create) | 220 | void * (*accf_create) | |
221 | (struct socket *, char *); | 221 | (struct socket *, char *); | |
222 | void (*accf_destroy) | 222 | void (*accf_destroy) | |
223 | (struct socket *); | 223 | (struct socket *); | |
224 | LIST_ENTRY(accept_filter) accf_next; | 224 | LIST_ENTRY(accept_filter) accf_next; | |
225 | u_int accf_refcnt; | 225 | u_int accf_refcnt; |