diff options
author | Brad King <brad.king@kitware.com> | 2018-01-22 15:18:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-01-22 15:18:44 (GMT) |
commit | 63f263b27fa9b9c63f038ff108118726bc9c5c64 (patch) | |
tree | 7022b7804d75353ed9d32570dff17b8ffe71feaf /Utilities/cmlibuv/src/unix/kqueue.c | |
parent | c81ace7ab7e5e325fef9339ed3ea05abbd0f8be4 (diff) | |
parent | 6db7b35236b81a73047a47c0f70f8befbf2ca51f (diff) | |
download | CMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.zip CMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.tar.gz CMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.tar.bz2 |
Merge topic 'update-libuv'
6db7b352 libuv: Update build within CMake
b58d48c1 Merge branch 'upstream-libuv' into update-libuv
f4a26c74 libuv 2018-01-19 (63de1eca)
e8b57c22 libuv: Teach import script to add missing newlines
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1666
Diffstat (limited to 'Utilities/cmlibuv/src/unix/kqueue.c')
-rw-r--r-- | Utilities/cmlibuv/src/unix/kqueue.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/Utilities/cmlibuv/src/unix/kqueue.c b/Utilities/cmlibuv/src/unix/kqueue.c index 6bc60bb..5e89bdc 100644 --- a/Utilities/cmlibuv/src/unix/kqueue.c +++ b/Utilities/cmlibuv/src/unix/kqueue.c @@ -34,6 +34,17 @@ #include <fcntl.h> #include <time.h> +/* + * Required on + * - Until at least FreeBSD 11.0 + * - Older versions of Mac OS X + * + * http://www.boost.org/doc/libs/1_61_0/boost/asio/detail/kqueue_reactor.hpp + */ +#ifndef EV_OOBAND +#define EV_OOBAND EV_FLAG1 +#endif + static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags); @@ -48,11 +59,12 @@ int uv__kqueue_init(uv_loop_t* loop) { } +#if defined(__APPLE__) static int uv__has_forked_with_cfrunloop; +#endif int uv__io_fork(uv_loop_t* loop) { int err; - uv__close(loop->backend_fd); loop->backend_fd = -1; err = uv__kqueue_init(loop); if (err) @@ -166,6 +178,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } } + if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) { + EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0); + + if (++nevents == ARRAY_SIZE(events)) { + if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) + abort(); + nevents = 0; + } + } + w->events = w->pevents; } @@ -275,6 +297,20 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } } + if (ev->filter == EV_OOBAND) { + if (w->pevents & UV__POLLPRI) { + revents |= UV__POLLPRI; + w->rcount = ev->data; + } else { + /* TODO batch up */ + struct kevent events[1]; + EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); + if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) + if (errno != ENOENT) + abort(); + } + } + if (ev->filter == EVFILT_WRITE) { if (w->pevents & POLLOUT) { revents |= POLLOUT; |