From: Niels Provos Date: Tue, 11 Jun 2002 18:38:37 +0000 (+0000) Subject: make kqueue work for callbacks that use both read and write events X-Git-Tag: release-1.1b~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=484e594e5cee77a4fc7b5c3c70809a8ae5aa9784;p=libevent make kqueue work for callbacks that use both read and write events simultaneously svn:r26 --- diff --git a/event.c b/event.c index 4802f3aa..4d5d6af7 100644 --- a/event.c +++ b/event.c @@ -343,6 +343,12 @@ event_del(struct event *ev) void event_active(struct event *ev, int res, short ncalls) { + /* We get different kinds of events, add them together */ + if (ev->ev_flags & EVLIST_ACTIVE) { + ev->ev_res |= res; + return; + } + ev->ev_res = res; ev->ev_ncalls = ncalls; ev->ev_pncalls = NULL; diff --git a/kqueue.c b/kqueue.c index 9daafa7e..38960dec 100644 --- a/kqueue.c +++ b/kqueue.c @@ -218,16 +218,37 @@ kq_dispatch(void *arg, struct timeval *tv) which |= EV_WRITE; } else if (events[i].filter == EVFILT_SIGNAL) { which |= EV_SIGNAL; - } + } else + events[i].filter = 0; + + if (!which) + continue; + + event_active(ev, which, + ev->ev_events & EV_SIGNAL ? events[i].data : 1); + } + + for (i = 0; i < res; i++) { + /* XXX */ + int ncalls, res; - if (which) { - if (!(ev->ev_events & EV_PERSIST)) { - ev->ev_flags &= ~EVLIST_X_KQINKERNEL; - event_del(ev); - } - event_active(ev, which, - ev->ev_events & EV_SIGNAL ? events[i].data : 1); + if (events[i].flags & EV_ERROR || events[i].filter == NULL) + continue; + + ev = events[i].udata; + if (ev->ev_events & EV_PERSIST) + continue; + + ncalls = 0; + if (ev->ev_flags & EVLIST_ACTIVE) { + ncalls = ev->ev_ncalls; + res = ev->ev_res; } + ev->ev_flags &= ~EVLIST_X_KQINKERNEL; + event_del(ev); + + if (ncalls) + event_active(ev, res, ncalls); } return (0);