make kqueue work for callbacks that use both read and write events

simultaneously


svn:r26
This commit is contained in:
Niels Provos 2002-06-11 18:38:37 +00:00
parent 3107493c97
commit 484e594e5c
2 changed files with 35 additions and 8 deletions

View File

@ -343,6 +343,12 @@ event_del(struct event *ev)
void void
event_active(struct event *ev, int res, short ncalls) 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_res = res;
ev->ev_ncalls = ncalls; ev->ev_ncalls = ncalls;
ev->ev_pncalls = NULL; ev->ev_pncalls = NULL;

View File

@ -218,16 +218,37 @@ kq_dispatch(void *arg, struct timeval *tv)
which |= EV_WRITE; which |= EV_WRITE;
} else if (events[i].filter == EVFILT_SIGNAL) { } else if (events[i].filter == EVFILT_SIGNAL) {
which |= EV_SIGNAL; which |= EV_SIGNAL;
} } else
events[i].filter = 0;
if (which) { if (!which)
if (!(ev->ev_events & EV_PERSIST)) { continue;
ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
event_del(ev); event_active(ev, which,
} ev->ev_events & EV_SIGNAL ? events[i].data : 1);
event_active(ev, which, }
ev->ev_events & EV_SIGNAL ? events[i].data : 1);
for (i = 0; i < res; i++) {
/* XXX */
int ncalls, res;
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); return (0);