git: kqueue: Only allow one thread to register event to a kqueue

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Fri Mar 4 06:22:32 PST 2016


commit 5c672d8fd9ab0898aec2a11f3386f222bb38d6c9
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Fri Mar 4 22:15:54 2016 +0800

    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.

Summary of changes:
 sys/kern/kern_event.c | 27 +++++++++++++++++++++++++++
 sys/sys/eventvar.h    |  2 ++
 2 files changed, 29 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/5c672d8fd9ab0898aec2a11f3386f222bb38d6c9


-- 
DragonFly BSD source repository


More information about the Commits mailing list