mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-14 14:54:49 -04:00
make kqueue work for callbacks that use both read and write events
simultaneously svn:r26
This commit is contained in:
parent
3107493c97
commit
484e594e5c
6
event.c
6
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;
|
||||
|
37
kqueue.c
37
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) {
|
||||
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 (!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 (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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user