Commit a5708d52 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Minor reorg of kqueue waiter for improved clarity

parent 23b1f977
......@@ -86,15 +86,16 @@ vwk_kq_sess(struct vwk *vwk, struct sess *sp, short arm)
vwk_kq_flush(vwk);
}
/*--------------------------------------------------------------------*/
static void
vwk_kev(struct vwk *vwk, const struct kevent *kp)
vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp)
{
int i, j;
struct sess *sp;
struct sess *ss[NKEV];
AN(kp->udata);
if (kp->udata == vwk->pipes) {
assert(kp->udata == vwk->pipes);
j = 0;
i = read(vwk->pipes[0], ss, sizeof ss);
if (i == -1 && errno == EAGAIN)
......@@ -108,8 +109,18 @@ vwk_kev(struct vwk *vwk, const struct kevent *kp)
i -= sizeof ss[0];
}
assert(i == 0);
return;
}
}
/*--------------------------------------------------------------------*/
static void
vwk_sess_ev(struct vwk *vwk, const struct kevent *kp)
{
int i;
struct sess *sp;
AN(kp->udata);
assert(kp->udata != vwk->pipes);
CAST_OBJ_NOTNULL(sp, kp->udata, SESS_MAGIC);
DSL(0x04, SLT_Debug, sp->vsl_id, "KQ: sp %p kev data %lu flags 0x%x%s",
sp, (unsigned long)kp->data, kp->flags,
......@@ -171,10 +182,13 @@ vwk_thread(void *priv)
for (kp = ke, j = 0; j < n; j++, kp++) {
if (kp->filter == EVFILT_TIMER) {
dotimer = 1;
continue;
}
} else if (kp->filter == EVFILT_READ &&
kp->udata == vwk->pipes) {
vwk_pipe_ev(vwk, kp);
} else {
assert(kp->filter == EVFILT_READ);
vwk_kev(vwk, kp);
vwk_sess_ev(vwk, kp);
}
}
if (!dotimer)
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment