Commit 3d186d94 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Relieve waiters of the task of receiving the request header, instead

throw the session at a worker thread the moment it becomes readable.
parent a5708d52
......@@ -920,8 +920,7 @@ void SES_Charge(struct sess *sp);
struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
void SES_DeletePool(struct sesspool *sp, struct worker *wrk);
int SES_Schedule(struct sess *sp);
void SES_Handle(struct sess *sp, int status);
void SES_Handle(struct sess *sp);
/* cache_shmlog.c */
extern struct VSC_C_main *VSC_C_main;
......
......@@ -1675,7 +1675,7 @@ CNT_Session(struct sess *sp)
*/
assert(
sp->step == STP_FIRST ||
sp->step == STP_START ||
sp->step == STP_WAIT ||
sp->step == STP_LOOKUP ||
sp->step == STP_RECV);
......
......@@ -279,23 +279,11 @@ SES_Schedule(struct sess *sp)
*/
void
SES_Handle(struct sess *sp, int status)
SES_Handle(struct sess *sp)
{
switch (status) {
case -2:
SES_Delete(sp, "blast");
break;
case -1:
SES_Delete(sp, "no request");
break;
case 1:
sp->step = STP_START;
(void)SES_Schedule(sp);
break;
default:
WRONG("Unexpected return from HTC_Rx()");
}
sp->step = STP_WAIT;
(void)SES_Schedule(sp);
}
/*--------------------------------------------------------------------
......
......@@ -129,13 +129,8 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep)
} else {
CAST_OBJ_NOTNULL(sp, ep->data.ptr, SESS_MAGIC);
if (ep->events & EPOLLIN || ep->events & EPOLLPRI) {
i = HTC_Rx(sp->htc);
if (i == 0) {
vwe_modadd(vwe, sp->fd, sp, EPOLL_CTL_MOD);
return; /* more needed */
}
VTAILQ_REMOVE(&vwe->sesshead, sp, list);
SES_Handle(sp, i);
SES_Handle(sp);
} else if (ep->events & EPOLLERR) {
VTAILQ_REMOVE(&vwe->sesshead, sp, list);
SES_Delete(sp, "ERR");
......
......@@ -116,7 +116,6 @@ vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp)
static void
vwk_sess_ev(struct vwk *vwk, const struct kevent *kp)
{
int i;
struct sess *sp;
AN(kp->udata);
......@@ -129,13 +128,8 @@ vwk_sess_ev(struct vwk *vwk, const struct kevent *kp)
assert((sp->vsl_id & VSL_IDENTMASK) == kp->ident);
assert((sp->vsl_id & VSL_IDENTMASK) == sp->fd);
if (kp->data > 0) {
i = HTC_Rx(sp->htc);
if (i == 0) {
vwk_kq_sess(vwk, sp, EV_ADD | EV_ONESHOT);
return; /* more needed */
}
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
SES_Handle(sp, i);
SES_Handle(sp);
return;
} else if (kp->flags & EV_EOF) {
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
......
......@@ -153,20 +153,10 @@ vwp_main(void *priv)
assert(vwp->pollfd[fd].fd == fd);
if (vwp->pollfd[fd].revents) {
v2--;
i = HTC_Rx(sp->htc);
if (vwp->pollfd[fd].revents != POLLIN)
VSL(SLT_Debug, fd, "Poll: %x / %d",
vwp->pollfd[fd].revents, i);
vwp->pollfd[fd].revents = 0;
VTAILQ_REMOVE(&vwp->sesshead, sp, list);
if (i == 0) {
/* Mov to front of list for speed */
VTAILQ_INSERT_HEAD(&vwp->sesshead,
sp, list);
} else {
vwp_unpoll(vwp, fd);
SES_Handle(sp, i);
}
vwp_unpoll(vwp, fd);
SES_Handle(sp);
} else if (sp->t_open <= deadline) {
VTAILQ_REMOVE(&vwp->sesshead, sp, list);
vwp_unpoll(vwp, fd);
......
......@@ -90,13 +90,6 @@ vws_port_ev(struct vws *vws, port_event_t *ev) {
SES_Delete(sp, "EOF");
return;
}
i = HTC_Rx(sp->htc);
if (i == 0) {
/* incomplete header, wait for more data */
vws_add(vws, sp->fd, sp);
return;
}
/*
* note: the original man page for port_associate(3C) states:
......@@ -115,7 +108,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev) {
VTAILQ_REMOVE(&vws->sesshead, sp, list);
/* SES_Handle will also handle errors */
SES_Handle(sp, i);
SES_Handle(sp);
}
return;
}
......
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