X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/4b05fe94e44407cd62092863e204337c521e7d8a..93de14fb2ac9996d3330d1fce388e75b3b2fb91a:/event.c?ds=sidebyside diff --git a/event.c b/event.c index 783eef1..5ed8bc5 100644 --- a/event.c +++ b/event.c @@ -144,7 +144,12 @@ x_cb (struct event *ev, int revents) static void x_cb_sig (EV_P_ struct ev_signal *w, int revents) { - x_cb ((struct event *)(((char *)w) - offsetof (struct event, iosig.sig)), revents); + struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.sig)); + + if (revents & EV_ERROR) + event_del (ev); + + x_cb (ev, revents); } static void @@ -152,7 +157,9 @@ x_cb_io (EV_P_ struct ev_io *w, int revents) { struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io)); - if (!(ev->ev_events & EV_PERSIST) && ev_is_active (w)) + if (revents & EV_ERROR) + event_del (ev); + else if (!(ev->ev_events & EV_PERSIST) && ev_is_active (w)) ev_io_stop (EV_A_ w); x_cb (ev, revents); @@ -241,6 +248,20 @@ int event_del (struct event *ev) return 0; } +void event_active (struct event *ev, int res, short ncalls) +{ + dLOOPev; + + if (res & EV_TIMEOUT) + ev_feed_event (EV_A_ &ev->to, res & EV_TIMEOUT); + + if (res & EV_SIGNAL) + ev_feed_event (EV_A_ &ev->iosig.sig, res & EV_SIGNAL); + + if (res & (EV_READ | EV_WRITE)) + ev_feed_event (EV_A_ &ev->iosig.io, res & (EV_READ | EV_WRITE)); +} + int event_pending (struct event *ev, short events, struct timeval *tv) { short revents = 0;