From e3c8cb7dfd8de508a89d304cef5fe9b86bdc08c7 Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Mon, 15 Oct 2018 20:55:18 +0100 Subject: [PATCH] FreeBSD: kevent is not a bitmask. The kevent does not take a bitmask. So if you register for READ|WRITE then it only registers READ since READ=-1 and WRITE=-2. This means that with an async socket connect then you do not get a callback on connect. So we need to register these separately. --- src/tvhpoll.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tvhpoll.c b/src/tvhpoll.c index 9e97647c6..b3292b348 100644 --- a/src/tvhpoll.c +++ b/src/tvhpoll.c @@ -198,11 +198,11 @@ static int tvhpoll_add0 const uint32_t oevents = tvhpoll_get_events(tp, fd); if (events == oevents) continue; tvhpoll_set_events(tp, fd, events); - if ((events & (TVHPOLL_OUT|TVHPOLL_IN)) == (TVHPOLL_OUT|TVHPOLL_IN)) { - EV_SET(ev+j, fd, EVFILT_READ|EVFILT_WRITE, EV_ADD, 0, 0, ptr); - j++; - continue; - } + /* Unlike poll, the kevent is not a bitmask (on FreeBSD, + * EVILT_READ=-1, EVFILT_WRITE=-2). That means if you OR them + * together then you only actually register READ, not WRITE. So, + * register them separately here. + */ if (events & TVHPOLL_OUT) { EV_SET(ev+j, fd, EVFILT_WRITE, EV_ADD, 0, 0, ptr); j++; -- 2.47.2