summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ev.c3
-rw-r--r--ev.h18
-rw-r--r--event.c17
3 files changed, 30 insertions, 8 deletions
diff --git a/ev.c b/ev.c
index f813e58..1cafd9b 100644
--- a/ev.c
+++ b/ev.c
@@ -489,6 +489,7 @@ siginit (EV_P)
ev_io_set (&sigev, sigpipe [0], EV_READ);
ev_io_start (&sigev);
+ ev_unref (EV_A); /* child watcher should not keep loop alive */
}
/*****************************************************************************/
@@ -641,6 +642,7 @@ ev_init (EV_P_ int methods)
ev_signal_init (&childev, childcb, SIGCHLD);
ev_set_priority (&childev, EV_MAXPRI);
ev_signal_start (EV_A_ &childev);
+ ev_unref (EV_A); /* child watcher should not keep loop alive */
#endif
}
}
@@ -913,7 +915,6 @@ ev_loop (EV_P_ int flags)
queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
call_pending (EV_A);
- printf ("activecnt %d\n", activecnt);//D
}
while (activecnt && !loop_done);
diff --git a/ev.h b/ev.h
index f8112b0..208ee70 100644
--- a/ev.h
+++ b/ev.h
@@ -44,10 +44,20 @@ typedef double ev_tstamp;
# define EV_MAXPRI +2
#endif
-#define EV_P void
-#define EV_P_
-#define EV_A
-#define EV_A_
+/* support multiple event loops? */
+#ifdef EV_MULTIPLICITY
+struct ev_loop;
+# define EV_P struct ev_loop *loop
+# define EV_P_ EV_P,
+# define EV_A loop
+# define EV_A_ EV_A,
+#else
+# define EV_P void
+# define EV_P_
+# define EV_A
+# define EV_A_
+
+#endif
/* eventmask, revents, events... */
#define EV_UNDEF -1 /* guaranteed to be invalid */
diff --git a/event.c b/event.c
index b1c335e..1c2bc73 100644
--- a/event.c
+++ b/event.c
@@ -35,11 +35,19 @@
#include "event.h"
-#define dLOOPev
-#define dLOOPbase
+#ifdef EV_MULTIPLICITY
+# define dLOOPev struct ev_loop *loop = ev->ev_base->loop
+# define dLOOPbase struct ev_loop *loop = base->loop
+#else
+# define dLOOPev
+# define dLOOPbase
+#endif
struct event_base
{
+#ifdef EV_MULTIPLICITY
+ struct ev_loop *loop;
+#endif
int dummy;
};
@@ -83,6 +91,8 @@ void *event_init (void)
void event_base_free (struct event_base *base)
{
+ dLOOPbase;
+
/* nop */
}
@@ -265,7 +275,8 @@ int event_base_set (struct event_base *base, struct event *ev)
int event_base_loop (struct event_base *base, int flags)
{
dLOOPbase;
- ev_loop (EV_A_ flags | EVLOOP_ONESHOT);
+
+ ev_loop (EV_A_ flags);
return 0;
}