From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Mon, 15 Oct 2018 19:55:18 +0000 (+0100) Subject: FreeBSD: kevent is not a bitmask. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3c8cb7dfd8de508a89d304cef5fe9b86bdc08c7;p=thirdparty%2Ftvheadend.git 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. --- 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++;