diff options
author | Ed Schouten <ed@FreeBSD.org> | 2015-08-12 17:46:26 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2015-08-12 17:46:26 +0000 |
commit | 880e2c6c52ba96641a072d83c0d95d1a5a2e7713 (patch) | |
tree | c91a9088228c5331031492771c878b1561ec7d84 /sys/kern/kern_event.c | |
parent | fbb624e76fde53c42737332510f37ee5a15b3069 (diff) | |
download | src-880e2c6c52ba96641a072d83c0d95d1a5a2e7713.tar.gz src-880e2c6c52ba96641a072d83c0d95d1a5a2e7713.zip |
Perform cleanups in response to D3307.
- Document the kern_kevent_anonymous() function.
- Add assertions to ensure that we don't silently leave the kqueue
linked from a file descriptor table.
Reviewed by: jmg
Differential Revision: https://reviews.freebsd.org/D3364
Notes
Notes:
svn path=/head/; revision=286681
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r-- | sys/kern/kern_event.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 2b43632c0b76..a4388aaf68d7 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -975,6 +975,10 @@ kern_kevent_fp(struct thread *td, struct file *fp, int nchanges, int nevents, return (error); } +/* + * Performs a kevent() call on a temporarily created kqueue. This can be + * used to perform one-shot polling, similar to poll() and select(). + */ int kern_kevent_anonymous(struct thread *td, int nevents, struct kevent_copyops *k_ops) @@ -1831,6 +1835,8 @@ static void kqueue_destroy(struct kqueue *kq) { + KASSERT(kq->kq_fdp == NULL, + ("kqueue still attached to a file descriptor")); seldrain(&kq->kq_sel); knlist_destroy(&kq->kq_sel.si_note); mtx_destroy(&kq->kq_lock); @@ -1863,6 +1869,7 @@ kqueue_close(struct file *fp, struct thread *td) * take the sleepable lock after non-sleepable. */ fdp = kq->kq_fdp; + kq->kq_fdp = NULL; if (!sx_xlocked(FILEDESC_LOCK(fdp))) { FILEDESC_XLOCK(fdp); filedesc_unlock = 1; |