Skip to content

Commit

Permalink
FreeBSD: kevent is not a bitmask.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
azlm8t authored and perexg committed Oct 16, 2018
1 parent f08bbef commit e3c8cb7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tvhpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit e3c8cb7

Please sign in to comment.