svn commit: r286681 - head/sys/kern
Ed Schouten
ed at FreeBSD.org
Wed Aug 12 17:46:27 UTC 2015
Author: ed
Date: Wed Aug 12 17:46:26 2015
New Revision: 286681
URL: https://svnweb.freebsd.org/changeset/base/286681
Log:
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
Modified:
head/sys/kern/kern_event.c
Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c Wed Aug 12 17:42:20 2015 (r286680)
+++ head/sys/kern/kern_event.c Wed Aug 12 17:46:26 2015 (r286681)
@@ -975,6 +975,10 @@ kern_kevent_fp(struct thread *td, struct
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 thr
* 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;
More information about the svn-src-all
mailing list