-
/*
* Copyright 2007 Marc Alexander Lehmann <libev@schmorp.de>
* Copyright 2000-2002 Niels Provos <provos@citi.umich.edu>
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);
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);
* 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
);
}
}
static void
-kqueue_init (struct event_base *base)
+kqueue_init (int flags)
{
struct kevent ch, ev;
/*
* 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
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);