aboutsummaryrefslogtreecommitdiff
path: root/sys/netncp/ncp_sock.c
diff options
context:
space:
mode:
authorSeigo Tanimura <tanimura@FreeBSD.org>2001-05-15 10:19:57 +0000
committerSeigo Tanimura <tanimura@FreeBSD.org>2001-05-15 10:19:57 +0000
commit1b36970495b471ac74bc1c7ecec6f4c896f32af2 (patch)
tree6c83742b01892cafae2ce46610557e85b1653352 /sys/netncp/ncp_sock.c
parentcd189e11950b76972ed468c1d243fb5551511661 (diff)
Back out scanning file descriptors with holding a process lock.
selrecord() requires allproc sx in pfind(), resulting in lock order reversal between allproc and a process lock.
Notes
Notes: svn path=/head/; revision=76618
Diffstat (limited to 'sys/netncp/ncp_sock.c')
-rw-r--r--sys/netncp/ncp_sock.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/netncp/ncp_sock.c b/sys/netncp/ncp_sock.c
index 063d0071a68b..2033441225ba 100644
--- a/sys/netncp/ncp_sock.c
+++ b/sys/netncp/ncp_sock.c
@@ -202,17 +202,31 @@ ncp_sock_rselect(struct socket *so,struct proc *p, struct timeval *tv, int event
}
timo = 0;
PROC_LOCK(p);
-retry:
p->p_flag |= P_SELECT;
+ PROC_UNLOCK(p);
error = ncp_poll(so, events);
+ PROC_LOCK(p);
if (error) {
error = 0;
goto done;
}
if (tv) {
getmicrouptime(&rtv);
- if (timevalcmp(&rtv, &atv, >=))
+ if (timevalcmp(&rtv, &atv, >=)) {
+ /*
+ * An event of our interest may occur during locking a process.
+ * In order to avoid missing the event that occured during locking
+ * the process, test P_SELECT and rescan file descriptors if
+ * necessary.
+ */
+ if ((p->p_flag & P_SELECT) == 0) {
+ p->p_flag |= P_SELECT;
+ PROC_UNLOCK(p);
+ error = ncp_poll(so, events);
+ PROC_LOCK(p);
+ }
goto done;
+ }
ttv=atv;
timevalsub(&ttv, &rtv);
timo = tvtohz(&ttv);