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

More acceptor work:

Make HTC_Rx() return a distinct value for overflow/blast.
Teach vca_handover() to handle HTC_Rx() return status
Use HTC_Rx/vca_handover this way in all three acceptors.
Eliminate vca_pollsession()
Teach CNT_First() about HTC_Rx states.
Log which acceptor we use in shmlog



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2084 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent daa3602a
......@@ -53,7 +53,6 @@
#include "cache.h"
#include "cache_acceptor.h"
static struct acceptor *vca_acceptors[] = {
#if defined(HAVE_KQUEUE)
&acceptor_kqueue,
......@@ -204,34 +203,25 @@ vca_acct(void *arg)
/*--------------------------------------------------------------------*/
void
vca_handover(struct sess *sp, int bad)
vca_handover(struct sess *sp, int status)
{
if (bad) {
vca_close_session(sp,
bad == 1 ? "overflow" : "no request");
switch (status) {
case -2:
vca_close_session(sp, "blast");
SES_Delete(sp);
break;
case -1:
vca_close_session(sp, "no request");
SES_Delete(sp);
return;
break;
case 1:
sp->step = STP_RECV;
WRK_QueueSession(sp);
break;
default:
INCOMPL();
}
sp->step = STP_RECV;
WRK_QueueSession(sp);
}
/*--------------------------------------------------------------------*/
int
vca_pollsession(struct sess *sp)
{
int i;
i = HTC_Rx(sp->htc);
/* XXX: fix retval */
if (i == 0) /* more needed */
return (-1);
if (i == 1) /* Yes, done */
return (0);
vca_close_session(sp, "err/poll");
return (1);
}
/*--------------------------------------------------------------------*/
......@@ -280,4 +270,5 @@ VCA_Init(void)
AZ(pipe(vca_pipes));
vca_act->init();
AZ(pthread_create(&vca_thread_acct, NULL, vca_acct, NULL));
VSL(SLT_Debug, 0, "Acceptor is %s", vca_act->name);
}
......@@ -52,5 +52,3 @@ extern struct acceptor acceptor_poll;
/* vca_acceptor.c */
void vca_handover(struct sess *sp, int bad);
int vca_pollsession(struct sess *sp);
......@@ -90,15 +90,11 @@ vca_main(void *arg)
vca_add(sp->fd, sp);
} else {
CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC);
i = vca_pollsession(sp);
if (i >= 0) {
i = HTC_Rx(sp->htc);
if (i != 0)
VTAILQ_REMOVE(&sesshead, sp, list);
if (sp->fd != -1)
vca_del(sp->fd);
if (i == 0)
vca_handover(sp, i);
else
SES_Delete(sp);
vca_del(sp->fd);
vca_handover(sp, i);
}
}
}
......
......@@ -102,13 +102,8 @@ vca_kev(const struct kevent *kp)
if (i == 0)
return; /* more needed */
VTAILQ_REMOVE(&sesshead, sp, list);
if (i > 0) {
vca_kq_sess(sp, EV_DELETE);
vca_handover(sp, i);
} else {
vca_close_session(sp, "err/poll");
SES_Delete(sp);
}
vca_kq_sess(sp, EV_DELETE);
vca_handover(sp, i);
return;
} else if (kp->flags == EV_EOF) {
VTAILQ_REMOVE(&sesshead, sp, list);
......
......@@ -131,15 +131,12 @@ vca_main(void *arg)
fd = sp->fd;
if (pollfd[fd].revents) {
v--;
i = vca_pollsession(sp);
if (i < 0)
i = HTC_Rx(sp->htc);
if (i == 0)
continue;
VTAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(fd);
if (i == 0)
vca_handover(sp, i);
else
SES_Delete(sp);
vca_handover(sp, i);
continue;
}
if (sp->t_open > deadline)
......
......@@ -370,17 +370,21 @@ cnt_first(struct sess *sp)
do
i = HTC_Rx(sp->htc);
while (i == 0);
if (i == 1) {
switch (i) {
case 1:
sp->step = STP_RECV;
return (0);
}
if (i == -1)
break;
case -1:
vca_close_session(sp, "error");
sp->step = STP_DONE;
break;
case -2:
vca_close_session(sp, "blast");
else if (i == 2)
vca_close_session(sp, "silent");
else
sp->step = STP_DONE;
break;
default:
INCOMPL();
sp->step = STP_DONE;
}
return (0);
}
......
......@@ -126,6 +126,7 @@ HTC_Reinit(struct http_conn *htc)
/*--------------------------------------------------------------------
* Receive more HTTP protocol bytes
* Returns:
* -2 overflow
* -1 error
* 0 more needed
* 1 got complete HTTP header
......@@ -138,9 +139,12 @@ HTC_Rx(struct http_conn *htc)
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */
if (i > 0)
i = read(htc->fd, htc->rxbuf.e, i);
if (i <= 0) {
WS_ReleaseP(htc->ws, htc->rxbuf.b);
return (-2);
}
i = read(htc->fd, htc->rxbuf.e, i);
if (i < 0) {
WS_ReleaseP(htc->ws, htc->rxbuf.b);
return (-1);
}
......
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