summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/bktr/bktr_core.c10
-rw-r--r--sys/dev/wscons/wsdisplay.c4
-rw-r--r--sys/kern/init_main.c4
-rw-r--r--sys/kern/kern_fork.c4
-rw-r--r--sys/kern/sys_generic.c56
-rw-r--r--sys/net/bpf.c4
-rw-r--r--sys/sys/proc.h4
-rw-r--r--sys/sys/selinfo.h9
8 files changed, 40 insertions, 55 deletions
diff --git a/sys/dev/pci/bktr/bktr_core.c b/sys/dev/pci/bktr/bktr_core.c
index 9afd9893bc6..3ffed6e1394 100644
--- a/sys/dev/pci/bktr/bktr_core.c
+++ b/sys/dev/pci/bktr/bktr_core.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bktr_core.c,v 1.23 2007/06/11 08:10:22 robert Exp $ */
+/* $OpenBSD: bktr_core.c,v 1.24 2007/07/25 23:11:52 art Exp $ */
/* $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.114 2000/10/31 13:09:56 roger Exp $ */
/*
@@ -651,7 +651,13 @@ common_bktr_intr( void *arg )
}
/* If someone has a select() on /dev/vbi, inform them */
- selwakeup(&bktr->vbi_select);
+#ifndef __OpenBSD__
+ if (bktr->vbi_select.si_pid) {
+#else
+ if (bktr->vbi_select.si_selpid) {
+#endif
+ selwakeup(&bktr->vbi_select);
+ }
}
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index f8a8fff7d2c..8a9c0ce496e 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.80 2007/04/10 22:37:17 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.81 2007/07/25 23:11:52 art Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -1402,7 +1402,7 @@ wsdisplaystart(struct tty *tp)
splx(s);
return;
}
- if (tp->t_outq.c_cc == 0 && tp->t_wsel.si_selproc == NULL)
+ if (tp->t_outq.c_cc == 0 && tp->t_wsel.si_selpid == 0)
goto low;
if ((scr = sc->sc_scr[WSDISPLAYSCREEN(tp->t_dev)]) == NULL) {
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index e6f95b17957..44d61a422d2 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.142 2007/06/01 19:25:09 deraadt Exp $ */
+/* $OpenBSD: init_main.c,v 1.143 2007/07/25 23:11:52 art Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -293,8 +293,6 @@ main(void *framep)
/* Create the file descriptor table. */
p->p_fd = fdinit(NULL);
- TAILQ_INIT(&p->p_selects);
-
/* Create the limits structures. */
p->p_p->ps_limit = &limit0;
for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index d4eb5fcc449..d54932106d7 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.91 2007/05/16 17:27:30 art Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.92 2007/07/25 23:11:52 art Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -280,8 +280,6 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
crhold(p1->p_ucred);
}
- TAILQ_INIT(&p2->p_selects);
-
/* bump references to the text vnode (for procfs) */
p2->p_textvp = p1->p_textvp;
if (p2->p_textvp)
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index a79c121c00c..f68f5251a7d 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.56 2007/03/24 16:01:22 art Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.57 2007/07/25 23:11:52 art Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -66,8 +66,6 @@ int selscan(struct proc *, fd_set *, fd_set *, int, int, register_t *);
int seltrue(dev_t, int, struct proc *);
void pollscan(struct proc *, struct pollfd *, u_int, register_t *);
-void sel_clean_proclist(struct proc *);
-
/*
* Read system call.
*/
@@ -710,7 +708,6 @@ retry:
if (error == 0)
goto retry;
done:
- sel_clean_proclist(p);
atomic_clearbits_int(&p->p_flag, P_SELECT);
/* select is not restarted after signals... */
if (error == ERESTART)
@@ -784,12 +781,17 @@ seltrue(dev_t dev, int events, struct proc *p)
void
selrecord(struct proc *selector, struct selinfo *sip)
{
- if (sip->si_selproc == NULL) {
- sip->si_selproc = selector;
- TAILQ_INSERT_TAIL(&selector->p_selects, sip, si_list);
- } else if (sip->si_selproc != selector) {
+ struct proc *p;
+ pid_t mypid;
+
+ mypid = selector->p_pid;
+ if (sip->si_selpid == mypid)
+ return;
+ if (sip->si_selpid && (p = pfind(sip->si_selpid)) &&
+ p->p_wchan == (caddr_t)&selwait)
sip->si_flags |= SI_COLL;
- }
+ else
+ sip->si_selpid = mypid;
}
/*
@@ -801,42 +803,25 @@ selwakeup(struct selinfo *sip)
struct proc *p;
int s;
+ if (sip->si_selpid == 0)
+ return;
if (sip->si_flags & SI_COLL) {
nselcoll++;
sip->si_flags &= ~SI_COLL;
wakeup(&selwait);
}
-
- /*
- * We check the process once before locking.
- * Then we wake the process and clean up its
- * selects list.
- */
- if (sip->si_selproc == NULL)
- return;
-
- SCHED_LOCK(s);
- if ((p = sip->si_selproc) != NULL) {
- if (p->p_wchan != NULL) {
+ p = pfind(sip->si_selpid);
+ sip->si_selpid = 0;
+ if (p != NULL) {
+ SCHED_LOCK(s);
+ if (p->p_wchan == (caddr_t)&selwait) {
if (p->p_stat == SSLEEP)
setrunnable(p);
else
unsleep(p);
- } else {
+ } else if (p->p_flag & P_SELECT)
atomic_clearbits_int(&p->p_flag, P_SELECT);
- }
- }
- SCHED_UNLOCK(s);
-}
-
-void
-sel_clean_proclist(struct proc *p)
-{
- struct selinfo *sip;
-
- while ((sip = TAILQ_FIRST(&p->p_selects)) != NULL) {
- sip->si_selproc = NULL;
- TAILQ_REMOVE(&p->p_selects, sip, si_list);
+ SCHED_UNLOCK(s);
}
}
@@ -947,7 +932,6 @@ retry:
goto retry;
done:
- sel_clean_proclist(p);
atomic_clearbits_int(&p->p_flag, P_SELECT);
/*
* NOTE: poll(2) is not restarted after a signal and EWOULDBLOCK is
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 0b3e79cd67e..15cfeecee8e 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.65 2007/03/24 16:01:22 art Exp $ */
+/* $OpenBSD: bpf.c,v 1.66 2007/07/25 23:11:53 art Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -496,6 +496,8 @@ bpf_wakeup(struct bpf_d *d)
d->bd_siguid, d->bd_sigeuid);
selwakeup(&d->bd_sel);
+ /* XXX */
+ d->bd_sel.si_selpid = 0;
KNOTE(&d->bd_sel.si_note, 0);
}
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index f029a82b7ce..125978d8a74 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.99 2007/05/31 22:07:53 thib Exp $ */
+/* $OpenBSD: proc.h,v 1.100 2007/07/25 23:11:53 art Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -225,8 +225,6 @@ struct proc {
sigset_t p_sigdivert; /* Signals to be diverted to thread. */
- TAILQ_HEAD(,selinfo) p_selects; /* selinfos we're selecting on */
-
/* End area that is zeroed on creation. */
#define p_endzero p_startcopy
diff --git a/sys/sys/selinfo.h b/sys/sys/selinfo.h
index 535b48deb42..b65a98db301 100644
--- a/sys/sys/selinfo.h
+++ b/sys/sys/selinfo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: selinfo.h,v 1.2 2007/03/24 16:01:22 art Exp $ */
+/* $OpenBSD: selinfo.h,v 1.3 2007/07/25 23:11:53 art Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,10 +41,9 @@
* notified when I/O becomes possible.
*/
struct selinfo {
- struct proc *si_selproc;
- TAILQ_ENTRY(selinfo) si_list; /* list of selinfo for a process */
- struct klist si_note; /* kernel note list */
- short si_flags; /* see below */
+ pid_t si_selpid; /* process to be notified */
+ struct klist si_note; /* kernel note list */
+ short si_flags; /* see below */
};
#define SI_COLL 0x0001 /* collision occurred */