summaryrefslogtreecommitdiffstats
path: root/sys/sys/event.h
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2019-12-12 16:31:06 +0000
committervisa <visa@openbsd.org>2019-12-12 16:31:06 +0000
commit696db59407941672885dff96f4aba7b78ea52eaa (patch)
tree7aa615d232d474b8908a6a7551501e6a4941a449 /sys/sys/event.h
parentUnhook <machine/stdarg.h> from <sys/stdarg.h>. Nowadays all the (diff)
downloadwireguard-openbsd-696db59407941672885dff96f4aba7b78ea52eaa.tar.xz
wireguard-openbsd-696db59407941672885dff96f4aba7b78ea52eaa.zip
Allow sleeping inside kqueue event filters.
In kqueue_scan(), threads have to get an exclusive access to a knote before processing by calling knote_acquire(). This prevents the knote from being destroyed while it is still in use. knote_acquire() also blocks other threads from processing the knote. Once knote processing has finished, the thread has to call knote_release(). The kqueue subsystem is still serialized by the kernel lock. If an event filter sleeps, the kernel lock is released and another thread might enter kqueue_scan(). kqueue_scan() uses start and end markers to keep track of the scan's progress and it has to be aware of other threads' markers. This patch is a revised version of mpi@'s work derived from DragonFly BSD. kqueue_check() has been adapted from NetBSD. Tested by anton@, sashan@ OK mpi@, anton@, sashan@
Diffstat (limited to 'sys/sys/event.h')
-rw-r--r--sys/sys/event.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/sys/event.h b/sys/sys/event.h
index e29c1128975..909367aea33 100644
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: event.h,v 1.30 2018/01/13 12:58:40 robert Exp $ */
+/* $OpenBSD: event.h,v 1.31 2019/12/12 16:31:06 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -125,6 +125,8 @@ SLIST_HEAD(klist, knote);
#ifdef _KERNEL
+#define EVFILT_MARKER 0xf /* placemarker for tailq */
+
/*
* hint flag for in-kernel use - must not equal any existing note
*/
@@ -170,6 +172,8 @@ struct knote {
#define KN_QUEUED 0x0002 /* event is on queue */
#define KN_DISABLED 0x0004 /* event is disabled */
#define KN_DETACHED 0x0008 /* knote is detached */
+#define KN_PROCESSING 0x0010 /* knote is being processed */
+#define KN_WAITING 0x0020 /* waiting on processing */
#define kn_id kn_kevent.ident
#define kn_filter kn_kevent.filter