From d47c2f0941d1cd829a9a070b4b74baf884b22505 Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 12 Apr 2015 06:52:43 +0000 Subject: MFC r280818: Make kevent(2) a cancellation point. --- lib/libthr/thread/thr_syscalls.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/libthr') diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c index 10fbad4..e71bf4a 100644 --- a/lib/libthr/thread/thr_syscalls.c +++ b/lib/libthr/thread/thr_syscalls.c @@ -341,6 +341,29 @@ __thr_pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, return (ret); } +static int +__thr_kevent(int kq, const struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, const struct timespec *timeout) +{ + struct pthread *curthread; + int ret; + + if (nevents == 0) { + /* + * No blocking, do not make the call cancellable. + */ + return (__sys_kevent(kq, changelist, nchanges, eventlist, + nevents, timeout)); + } + curthread = _get_curthread(); + _thr_cancel_enter(curthread); + ret = __sys_kevent(kq, changelist, nchanges, eventlist, nevents, + timeout); + _thr_cancel_leave(curthread, ret == -1 && nchanges == 0); + + return (ret); +} + /* * Cancellation behavior: * Thread may be canceled at start, but if the system call got some data, @@ -599,6 +622,7 @@ __thr_interpose_libc(void) SLOT(writev); SLOT(spinlock); SLOT(spinunlock); + SLOT(kevent); #undef SLOT *(__libc_interposing_slot( INTERPOS__pthread_mutex_init_calloc_cb)) = -- cgit v1.1