X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/120eeba0bed6b77e91b32b8cd0fb875c314bc092..b8c10cda08d48348f422bb3d31f019584cf252c9:/ev_kqueue.c?ds=inline diff --git a/ev_kqueue.c b/ev_kqueue.c index 8785d10..4bbcf39 100644 --- a/ev_kqueue.c +++ b/ev_kqueue.c @@ -1,4 +1,3 @@ - /* * Copyright 2007 Marc Alexander Lehmann * Copyright 2000-2002 Niels Provos @@ -56,10 +55,14 @@ kqueue_change (int fd, int filter, int flags, int fflags) ke->fflags = fflags; } +#ifndef NOTE_EOF +# define NOTE_EOF 0 +#endif + static void kqueue_modify (int fd, int oev, int nev) { - if ((oev ^ new) & EV_READ) + if ((oev ^ nev) & EV_READ) { if (nev & EV_READ) kqueue_change (fd, EVFILT_READ, EV_ADD, NOTE_EOF); @@ -67,7 +70,7 @@ kqueue_modify (int fd, int oev, int nev) kqueue_change (fd, EVFILT_READ, EV_DELETE, 0); } - if ((oev ^ new) & EV_WRITE) + if ((oev ^ nev) & EV_WRITE) { if (nev & EV_WRITE) kqueue_change (fd, EVFILT_WRITE, EV_ADD, NOTE_EOF); @@ -106,14 +109,14 @@ kqueue_poll (ev_tstamp timeout) * an event we are still processing. In that case * the data field is set to ENOENT. */ - if (events [i].data == EBADF) - fd_kill (events [i].ident); + if (kq_events [i].data == EBADF) + fd_kill (kq_events [i].ident); } else fd_event ( - events [i].ident, - events [i].filter == EVFILT_READ ? EV_READ - : events [i].filter == EVFILT_WRITE ? EV_WRITE + kq_events [i].ident, + kq_events [i].filter == EVFILT_READ ? EV_READ + : kq_events [i].filter == EVFILT_WRITE ? EV_WRITE : 0 ); } @@ -127,7 +130,7 @@ kqueue_poll (ev_tstamp timeout) } static void -kqueue_init (struct event_base *base) +kqueue_init (int flags) { struct kevent ch, ev; @@ -142,7 +145,7 @@ kqueue_init (struct event_base *base) /* * If kqueue works, then kevent will succeed, and it will - * stick an error in events[0]. If kqueue is broken, then + * stick an error in ev. If kqueue is broken, then * kevent will fail. */ if (kevent (kq_fd, &ch, 1, &ev, 1, 0) != 1 @@ -156,8 +159,8 @@ kqueue_init (struct event_base *base) ev_method = EVMETHOD_KQUEUE; method_fudge = 1e-3; /* needed to compensate for kevent returning early */ - method_modify = kq_modify; - method_poll = kq_poll; + method_modify = kqueue_modify; + method_poll = kqueue_poll; kq_eventmax = 64; /* intiial number of events receivable per poll */ kq_events = malloc (sizeof (struct kevent) * kq_eventmax);