Date: Wed, 12 Aug 2015 17:46:27 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286681 - head/sys/kern Message-ID: <201508121746.t7CHkR4B050171@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508121746.t7CHkR4B050171>