summaryrefslogtreecommitdiff
path: root/ev_kqueue.c
diff options
context:
space:
mode:
authorroot <root>2007-11-04 15:58:49 +0000
committerroot <root>2007-11-04 15:58:49 +0000
commit5e20ccfe261679c78f9aa365ac087fb0700e0f2b (patch)
tree1a45e376caae037cc6a6bedbf0f7d95fde17701d /ev_kqueue.c
parentbaf84e3741d88472c270efb118be8e3621ebe2d8 (diff)
better destroy support, separate into default loop and additional loops
Diffstat (limited to 'ev_kqueue.c')
-rw-r--r--ev_kqueue.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ev_kqueue.c b/ev_kqueue.c
index 8282fea..2de8874 100644
--- a/ev_kqueue.c
+++ b/ev_kqueue.c
@@ -133,6 +133,8 @@ kqueue_init (EV_P_ int flags)
if ((kqueue_fd = kqueue ()) < 0)
return 0;
+ fcntl (kqueue_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
+
/* Check for Mac OS X kqueue bug. */
ch.ident = -1;
ch.filter = EVFILT_READ;
@@ -159,6 +161,29 @@ kqueue_init (EV_P_ int flags)
kqueue_eventmax = 64; /* intiial number of events receivable per poll */
kqueue_events = malloc (sizeof (struct kevent) * kqueue_eventmax);
+ kqueue_changes = 0;
+ kqueue_changemax = 0;
+ kqueue_changecnt = 0;
+
return EVMETHOD_KQUEUE;
}
+static void
+kqueue_destroy (EV_P)
+{
+ close (kqueue_fd);
+
+ free (kqueue_events);
+ free (kqueue_changes);
+}
+
+static void
+kqueue_fork (EV_P)
+{
+ kqueue_fd = kqueue ();
+ fcntl (kqueue_fd, F_SETFD, FD_CLOEXEC);
+
+ /* re-register interest in fds */
+ fd_rearm_all ();
+}
+