OpenBSD cvs log

created 2020-01-21T20:43:55Z
begin 2019-12-12T15:55:36Z
end 2019-12-12T16:31:06Z
path src/sys
commits 1

date 2019-12-12T16:31:06Z
author visa
files src/sys/kern/kern_event.c log diff annotate
src/sys/sys/event.h log diff annotate
message 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@