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: svn+ssh://projects.linpro.no/svn/varnish/trunk@2084
d4fa192b-c00b-0410-8231-
f00ffab90ce4
#include "cache.h"
#include "cache_acceptor.h"
-
static struct acceptor *vca_acceptors[] = {
#if defined(HAVE_KQUEUE)
&acceptor_kqueue,
/*--------------------------------------------------------------------*/
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);
}
/*--------------------------------------------------------------------*/
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);
}
/* vca_acceptor.c */
void vca_handover(struct sess *sp, int bad);
-int vca_pollsession(struct sess *sp);
-
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);
}
}
}
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);
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)
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);
}
/*--------------------------------------------------------------------
* Receive more HTTP protocol bytes
* Returns:
+ * -2 overflow
* -1 error
* 0 more needed
* 1 got complete HTTP header
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);
}