summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2004-08-15 06:24:42 +0000
committerjmg <jmg@FreeBSD.org>2004-08-15 06:24:42 +0000
commitbc1805c6e871c178d0b6516c3baa774ffd77224a (patch)
tree1172b68a7c9e7fa73090ae134eb98825bdab8ad6 /sys/kern/kern_exit.c
parent57da12d01618c3ef2590eab07e71f69d16ead13a (diff)
downloadFreeBSD-src-bc1805c6e871c178d0b6516c3baa774ffd77224a.zip
FreeBSD-src-bc1805c6e871c178d0b6516c3baa774ffd77224a.tar.gz
Add locking to the kqueue subsystem. This also makes the kqueue subsystem
a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index f53aa47..96e9cf2 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -438,18 +438,17 @@ retry:
mtx_unlock_spin(&sched_lock);
ruadd(p->p_ru, &p->p_stats->p_cru);
+ mtx_unlock(&Giant);
/*
* Notify interested parties of our demise.
*/
- KNOTE(&p->p_klist, NOTE_EXIT);
- mtx_unlock(&Giant);
+ KNOTE_LOCKED(&p->p_klist, NOTE_EXIT);
/*
* Just delete all entries in the p_klist. At this point we won't
* report any more events, and there are nasty race conditions that
* can beat us if we don't.
*/
- while (SLIST_FIRST(&p->p_klist))
- SLIST_REMOVE_HEAD(&p->p_klist, kn_selnext);
+ knlist_clear(&p->p_klist, 1);
/*
* Notify parent that we're gone. If parent has the PS_NOCLDWAIT
@@ -533,6 +532,12 @@ retry:
sched_exit(p->p_pptr, td);
/*
+ * hopefully no one will try to deliver a signal to the process this
+ * late in the game.
+ */
+ knlist_destroy(&p->p_klist);
+
+ /*
* Make sure the scheduler takes this thread out of its tables etc.
* This will also release this thread's reference to the ucred.
* Other thread parts to release include pcb bits and such.
OpenPOWER on IntegriCloud