diff options
author | kib <kib@FreeBSD.org> | 2015-04-12 06:52:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-04-12 06:52:43 +0000 |
commit | d47c2f0941d1cd829a9a070b4b74baf884b22505 (patch) | |
tree | add53e0078c23fa9db08e08b8b25d45859411ba7 /lib/libthr | |
parent | 39372044850f47dd4bea491cc717b227b8214a46 (diff) | |
download | FreeBSD-src-d47c2f0941d1cd829a9a070b4b74baf884b22505.zip FreeBSD-src-d47c2f0941d1cd829a9a070b4b74baf884b22505.tar.gz |
MFC r280818:
Make kevent(2) a cancellation point.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_syscalls.c | 24 |
1 files changed, 24 insertions, 0 deletions
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)) = |