Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.150 retrieving revision 1.151.2.1 diff -u -p -r1.150 -r1.151.2.1 --- src/sys/kern/uipc_socket.c 2007/12/16 21:25:59 1.150 +++ src/sys/kern/uipc_socket.c 2008/03/24 07:16:14 1.151.2.1 @@ -1,7 +1,7 @@ -/* $NetBSD: uipc_socket.c,v 1.150 2007/12/16 21:25:59 elad Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.151.2.1 2008/03/24 07:16:14 keiichi Exp $ */ /*- - * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * Copyright (c) 2002, 2007, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.150 2007/12/16 21:25:59 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.151.2.1 2008/03/24 07:16:14 keiichi Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -280,7 +280,7 @@ sodoloanfree(struct vm_page **pgs, void } static size_t -sodopendfree() +sodopendfree(void) { size_t rv; @@ -299,7 +299,7 @@ sodopendfree() */ static size_t -sodopendfreel() +sodopendfreel(void) { struct mbuf *m, *next; size_t rv = 0; @@ -660,8 +660,7 @@ soclose(struct socket *so) goto drop; } if (so->so_options & SO_LINGER) { - if ((so->so_state & SS_ISDISCONNECTING) && - (so->so_state & SS_NBIO)) + if ((so->so_state & SS_ISDISCONNECTING) && so->so_nbio) goto drop; while (so->so_state & SS_ISCONNECTED) { error = tsleep((void *)&so->so_timeo, @@ -870,7 +869,7 @@ sosend(struct socket *so, struct mbuf *a snderr(EMSGSIZE); if (space < resid + clen && (atomic || space < so->so_snd.sb_lowat || space < clen)) { - if (so->so_state & SS_NBIO) + if (so->so_nbio) snderr(EWOULDBLOCK); sbunlock(&so->so_snd); error = sbwait(&so->so_snd); @@ -1110,7 +1109,7 @@ soreceive(struct socket *so, struct mbuf } if (uio->uio_resid == 0) goto release; - if ((so->so_state & SS_NBIO) || (flags & MSG_DONTWAIT)) { + if (so->so_nbio || (flags & MSG_DONTWAIT)) { error = EWOULDBLOCK; goto release; } @@ -1683,8 +1682,9 @@ sogetopt(struct socket *so, int level, i void sohasoutofband(struct socket *so) { + fownsignal(so->so_pgid, SIGURG, POLL_PRI, POLLPRI|POLLRDBAND, so); - selwakeup(&so->so_rcv.sb_sel); + selnotify(&so->so_rcv.sb_sel, POLLPRI | POLLRDBAND, 0); } static void @@ -1802,6 +1802,59 @@ soo_kqfilter(struct file *fp, struct kno return (0); } +static int +sodopoll(struct socket *so, int events) +{ + int revents; + + revents = 0; + + if (events & (POLLIN | POLLRDNORM)) + if (soreadable(so)) + revents |= events & (POLLIN | POLLRDNORM); + + if (events & (POLLOUT | POLLWRNORM)) + if (sowritable(so)) + revents |= events & (POLLOUT | POLLWRNORM); + + if (events & (POLLPRI | POLLRDBAND)) + if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) + revents |= events & (POLLPRI | POLLRDBAND); + + return revents; +} + +int +sopoll(struct socket *so, int events) +{ + int revents = 0; + int s; + + if ((revents = sodopoll(so, events)) != 0) + return revents; + + KERNEL_LOCK(1, curlwp); + s = splsoftnet(); + + if ((revents = sodopoll(so, events)) == 0) { + if (events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { + selrecord(curlwp, &so->so_rcv.sb_sel); + so->so_rcv.sb_flags |= SB_SEL; + } + + if (events & (POLLOUT | POLLWRNORM)) { + selrecord(curlwp, &so->so_snd.sb_sel); + so->so_snd.sb_flags |= SB_SEL; + } + } + + splx(s); + KERNEL_UNLOCK_ONE(curlwp); + + return revents; +} + + #include static int sysctl_kern_somaxkva(SYSCTLFN_PROTO);