X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/9151dfde678354ca3b8dc113f732a06e58140c82..73861ad6c4342633fff7dcd5913bcaa2749dba09:/ev.c diff --git a/ev.c b/ev.c index a111beb..3f9fe2b 100644 --- a/ev.c +++ b/ev.c @@ -927,8 +927,8 @@ ev_recommended_backends (void) unsigned int ev_embeddable_backends (void) { - return EVBACKEND_EPOLL - | EVBACKEND_KQUEUE + /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ + return EVBACKEND_KQUEUE | EVBACKEND_PORT; } @@ -2184,11 +2184,11 @@ ev_check_stop (EV_P_ ev_check *w) void noinline ev_embed_sweep (EV_P_ ev_embed *w) { - ev_loop (w->loop, EVLOOP_NONBLOCK); + ev_loop (w->other, EVLOOP_NONBLOCK); } static void -embed_cb (EV_P_ ev_io *io, int revents) +embed_io_cb (EV_P_ ev_io *io, int revents) { ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); @@ -2198,6 +2198,14 @@ embed_cb (EV_P_ ev_io *io, int revents) ev_embed_sweep (loop, w); } +static void +embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) +{ + ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); + + fd_reify (w->other); +} + void ev_embed_start (EV_P_ ev_embed *w) { @@ -2205,14 +2213,18 @@ ev_embed_start (EV_P_ ev_embed *w) return; { - struct ev_loop *loop = w->loop; + struct ev_loop *loop = w->other; assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); - ev_io_init (&w->io, embed_cb, backend_fd, EV_READ); + ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); } ev_set_priority (&w->io, ev_priority (w)); ev_io_start (EV_A_ &w->io); + ev_prepare_init (&w->prepare, embed_prepare_cb); + ev_set_priority (&w->prepare, EV_MINPRI); + ev_prepare_start (EV_A_ &w->prepare); + ev_start (EV_A_ (W)w, 1); } @@ -2224,6 +2236,7 @@ ev_embed_stop (EV_P_ ev_embed *w) return; ev_io_stop (EV_A_ &w->io); + ev_prepare_stop (EV_A_ &w->prepare); ev_stop (EV_A_ (W)w); } @@ -2322,6 +2335,10 @@ ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, vo } } +#if EV_MULTIPLICITY + #include "ev_wrap.h" +#endif + #ifdef __cplusplus } #endif