diff options
author | tanimura <tanimura@FreeBSD.org> | 2001-05-14 05:26:48 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2001-05-14 05:26:48 +0000 |
commit | 90ac553bec09bba7ec7832b74ff5390e11421b14 (patch) | |
tree | 6e6f3d78ddb96218fc7b19a7e41165b65e2c1100 /sys/netncp | |
parent | ee368059840ce13cb43ccfbcfb7d4fcb8e06f76c (diff) | |
download | FreeBSD-src-90ac553bec09bba7ec7832b74ff5390e11421b14.zip FreeBSD-src-90ac553bec09bba7ec7832b74ff5390e11421b14.tar.gz |
- Convert msleep(9) in select(2) and poll(2) to cv_*wait*(9).
- Since polling should not involve sleeping, keep holding a
process lock upon scanning file descriptors.
- Hold a reference to every file descriptor prior to entering
polling loop in order to avoid lock order reversal between
lockmgr and p_mtx upon calling fdrop() in fo_poll().
(NOTE: this work has not been done for netncp and netsmb
yet because a socket itself has no reference counts.)
Reviewed by: jhb
Diffstat (limited to 'sys/netncp')
-rw-r--r-- | sys/netncp/ncp_sock.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/netncp/ncp_sock.c b/sys/netncp/ncp_sock.c index 6503c2b..063d007 100644 --- a/sys/netncp/ncp_sock.c +++ b/sys/netncp/ncp_sock.c @@ -46,6 +46,7 @@ #include <sys/uio.h> #include <sys/syslog.h> #include <sys/mbuf.h> +#include <sys/condvar.h> #include <net/route.h> #include <netipx/ipx.h> @@ -188,18 +189,19 @@ int ncp_sock_rselect(struct socket *so,struct proc *p, struct timeval *tv, int events) { struct timeval atv,rtv,ttv; - int s,timo,error=0; + int timo,error=0; if (tv) { atv=*tv; if (itimerfix(&atv)) { error = EINVAL; - goto done; + goto done_noproclock; } getmicrouptime(&rtv); timevaladd(&atv, &rtv); } timo = 0; + PROC_LOCK(p); retry: p->p_flag |= P_SELECT; error = ncp_poll(so, events); @@ -215,16 +217,18 @@ retry: timevalsub(&ttv, &rtv); timo = tvtohz(&ttv); } - s = splhigh(); - if ((p->p_flag & P_SELECT) == 0) { - splx(s); - goto retry; - } p->p_flag &= ~P_SELECT; - error = tsleep((caddr_t)&selwait, PSOCK, "ncpslt", timo); - splx(s); + if (timo > 0) + error = cv_timedwait(&selwait, &p->p_mtx, timo); + else { + cv_wait(&selwait, &p->p_mtx); + error = 0; + } + done: p->p_flag &= ~P_SELECT; + PROC_UNLOCK(p); +done_noproclock: if (error == ERESTART) { /* printf("Signal: %x", CURSIG(p));*/ error = 0; |