- ev_method = EVMETHOD_KQUEUE;
- method_fudge = 1e-3; /* needed to compensate for kevent returning early */
- method_modify = kqueue_modify;
- method_poll = kqueue_poll;
+ backend_fudge = 1e-3; /* needed to compensate for kevent returning early */
+ backend_modify = kqueue_modify;
+ backend_poll = kqueue_poll;
+
+ kqueue_eventmax = 64; /* intiial number of events receivable per poll */
+ kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
+
+ kqueue_changes = 0;
+ kqueue_changemax = 0;
+ kqueue_changecnt = 0;
+
+ return EVBACKEND_KQUEUE;
+}
+
+static void
+kqueue_destroy (EV_P)
+{
+ close (kqueue_fd);
+
+ ev_free (kqueue_events);
+ ev_free (kqueue_changes);
+}
+
+static void
+kqueue_fork (EV_P)
+{
+ close (kqueue_fd);
+
+ while ((kqueue_fd = kqueue ()) < 0)
+ syserr ("(libev) kqueue");
+
+ fcntl (kqueue_fd, F_SETFD, FD_CLOEXEC);