]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
FreeBSD: kevent is not a bitmask.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Mon, 15 Oct 2018 19:55:18 +0000 (20:55 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 16 Oct 2018 14:51:46 +0000 (16:51 +0200)
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

index 9e97647c6e3430c37ec5f84ebfefec6d6d5748f7..b3292b348c5314bfe9433dd31da9ea706cb4a935 100644 (file)
@@ -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++;