X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/8ee8df9cf84f6ae595eb82ebe7e5eb119112087e..149ff7181e0f706d39af5f837a6da24fcfc50cbb:/ev_kqueue.c?ds=inline diff --git a/ev_kqueue.c b/ev_kqueue.c index e68654f..8785d10 100644 --- a/ev_kqueue.c +++ b/ev_kqueue.c @@ -110,7 +110,7 @@ kqueue_poll (ev_tstamp timeout) fd_kill (events [i].ident); } else - event ( + fd_event ( events [i].ident, events [i].filter == EVFILT_READ ? EV_READ : events [i].filter == EVFILT_WRITE ? EV_WRITE @@ -129,41 +129,27 @@ kqueue_poll (ev_tstamp timeout) static void kqueue_init (struct event_base *base) { - /* Initalize the kernel queue */ - if ((kq_fd = kqueue ()) == -1) - { - free (kqueueop); - return; - } + struct kevent ch, ev; - /* Initalize fields */ - kq_changes = malloc (NEVENT * sizeof (struct kevent)); - if (!kq_changes) + /* Initalize the kernel queue */ + if ((kq_fd = kqueue ()) < 0) return; - events = malloc (NEVENT * sizeof (struct kevent)); - if (!events) - { - free (kq_changes); - return; - } - /* Check for Mac OS X kqueue bug. */ - kq_changes [0].ident = -1; - kq_changes [0].filter = EVFILT_READ; - kq_changes [0].flags = EV_ADD; + ch.ident = -1; + ch.filter = EVFILT_READ; + ch.flags = EV_ADD; + /* * If kqueue works, then kevent will succeed, and it will * stick an error in events[0]. If kqueue is broken, then * kevent will fail. */ - if (kevent (kq_fd, kq_changes, 1, kq_events, NEVENT, NULL) != 1 - || kq_events[0].ident != -1 - || kq_events[0].flags != EV_ERROR) + if (kevent (kq_fd, &ch, 1, &ev, 1, 0) != 1 + || ev.ident != -1 + || ev.flags != EV_ERROR) { /* detected broken kqueue */ - free (kq_changes); - free (kq_events); close (kq_fd); return; }