kqueue: Only allow one thread to register event to a kqueue
commit5c672d8fd9ab0898aec2a11f3386f222bb38d6c9
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 4 Mar 2016 14:15:54 +0000 (4 22:15 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 4 Mar 2016 14:15:54 +0000 (4 22:15 +0800)
tree66cf062a09e21a3c1f48fa57607a5e2b7b11c4f1
parentc995a55de10136c7802e86c68e60641021ea01bb
kqueue: Only allow one thread to register event to a kqueue

This prevents various races on the registration path, if it
ever blocks (kq token will be released):
- Kqueue hash table creation; the malloc(M_WAIT) could block.
- Install a new event.  Holding the token protect the klist could block.

Since kqueue _should_ rarely be shared between threads, allowing one
thread to do the event registration to a kqueue can work well enough.
sys/kern/kern_event.c
sys/sys/eventvar.h