From abfc4f0b15e3543425106a4b0bccd00a46ba5446 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 24 Nov 2021 19:37:02 -0500 Subject: [PATCH] kqueue: ignore write-end closed notifications (#3277) The combination EVFILT_WRITE+EV_EOF is valid and indicates that the reader has disconnected (called `shutdown(SHUT_RD)`). Probably very rare in practice, but this seems more correct. Issue noticed (for UV_DISCONNECT clients of uv_poll), while doing research for https://github.com/libuv/libuv/pull/3250. --- src/unix/kqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c index bf183d5fd..75e911070 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c @@ -326,6 +326,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (errno != ENOENT) abort(); } + if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) + revents |= UV__POLLRDHUP; } if (ev->filter == EV_OOBAND) { @@ -359,9 +361,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (ev->flags & EV_ERROR) revents |= POLLERR; - if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) - revents |= UV__POLLRDHUP; - if (revents == 0) continue;