From fa0617660a9f288caade3c00382fbe3b3c2ffa6d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 13 Mar 2017 20:49:56 +0100 Subject: [PATCH] MEDIUM: kqueue: only set FD_POLL_IN when there are pending data Let's avoid setting FD_POLL_IN when there's no pending data. It will save a useless recv() syscall on pure closes. --- src/ev_kqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c index 6f41c731f..f1c0b8d00 100644 --- a/src/ev_kqueue.c +++ b/src/ev_kqueue.c @@ -125,7 +125,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp) fdtab[fd].ev &= FD_POLL_STICKY; if (kev[count].filter == EVFILT_READ) { - fdtab[fd].ev |= FD_POLL_IN; + if (kev[count].data) + fdtab[fd].ev |= FD_POLL_IN; if (kev[count].flags & EV_EOF) fdtab[fd].ev |= FD_POLL_HUP; }