X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/5e20ccfe261679c78f9aa365ac087fb0700e0f2b..e7d1fc1a4bbd47e0d2f7d59d1ce4ccaa4fa0ab10:/ev_kqueue.c diff --git a/ev_kqueue.c b/ev_kqueue.c index 2de8874..8d5021f 100644 --- a/ev_kqueue.c +++ b/ev_kqueue.c @@ -85,7 +85,12 @@ kqueue_poll (EV_P_ ev_tstamp timeout) kqueue_changecnt = 0; if (res < 0) - return; + { + if (errno != EINTR) + syserr ("(libev) kevent"); + + return; + } for (i = 0; i < res; ++i) { @@ -118,9 +123,9 @@ kqueue_poll (EV_P_ ev_tstamp timeout) if (expect_false (res == kqueue_eventmax)) { - free (kqueue_events); + ev_free (kqueue_events); kqueue_eventmax = array_roundsize (kqueue_events, kqueue_eventmax << 1); - kqueue_events = malloc (sizeof (struct kevent) * kqueue_eventmax); + kqueue_events = ev_malloc (sizeof (struct kevent) * kqueue_eventmax); } } @@ -159,7 +164,7 @@ kqueue_init (EV_P_ int flags) method_poll = kqueue_poll; kqueue_eventmax = 64; /* intiial number of events receivable per poll */ - kqueue_events = malloc (sizeof (struct kevent) * kqueue_eventmax); + kqueue_events = ev_malloc (sizeof (struct kevent) * kqueue_eventmax); kqueue_changes = 0; kqueue_changemax = 0; @@ -173,17 +178,21 @@ kqueue_destroy (EV_P) { close (kqueue_fd); - free (kqueue_events); - free (kqueue_changes); + ev_free (kqueue_events); + ev_free (kqueue_changes); } static void kqueue_fork (EV_P) { - kqueue_fd = kqueue (); + close (kqueue_fd); + + while ((kqueue_fd = kqueue ()) < 0) + syserr ("(libev) kqueue"); + fcntl (kqueue_fd, F_SETFD, FD_CLOEXEC); /* re-register interest in fds */ - fd_rearm_all (); + fd_rearm_all (EV_A); }