From 6f096c9d03cdaee08b428cbfd69b221a0ce9b846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9?= Date: Mon, 16 Mar 2026 21:23:06 -0500 Subject: [PATCH] darwin: replace EV_OOBAND handling with EVFILT_EXCEPT + NOTE_OOB (#4906) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/libuv/libuv/issues/3947 Re-lands: https://github.com/libuv/libuv/pull/4597 Signed-off-by: Juan José Arboleda --- src/unix/kqueue.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c index 27d288143..da19e3bc8 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c @@ -229,7 +229,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) { +#ifdef __APPLE__ + /* + * Use EVFILT_EXCEPT+ NOTE_OOB for macOS since it defines this flag. + * FreeBSD does not. + * Refs: https://github.com/libuv/libuv/issues/3947 + */ + EV_SET(events + nevents, w->fd, EVFILT_EXCEPT, EV_ADD, NOTE_OOB, 0, 0); +#else EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0); +#endif if (++nevents == ARRAY_SIZE(events)) { if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) @@ -369,7 +378,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { revents |= UV__POLLRDHUP; } +#ifdef __APPLE__ + /* Match EVFILT_EXCEPT used above for macOS. */ + if (ev->filter == EVFILT_EXCEPT) { +#else if (ev->filter == EV_OOBAND) { +#endif if (w->pevents & UV__POLLPRI) revents |= UV__POLLPRI; else