From 6db8d161c17f1db0580cd9b7a1e996be012be8ac Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 21 Aug 2006 12:12:16 +0000 Subject: [PATCH] Create the possiblity for the the acceptor to send the session directly to the workerpool instead of taking the detour around the session-herder. This saves a context switch and is presumabley a good idea because the majority of sessions will have requst already in the pipeline. For accept filters it makes even more sense because we know this to be the case. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@866 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_acceptor.c | 19 +++++++++++++ varnish-cache/bin/varnishd/cache_acceptor.h | 1 + varnish-cache/bin/varnishd/cache_center.c | 30 +++++++++++++++++++++ varnish-cache/bin/varnishd/steps.h | 1 + 4 files changed, 51 insertions(+) diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index ef84e85d..4ff494fc 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -84,6 +84,15 @@ vca_accept_sess(int fd) AZ(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv)); } #endif +#ifdef SO_RCVTIMEO + { + struct timeval tv; + + tv.tv_sec = params->sess_timeout; + tv.tv_usec = 0; + AZ(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv)); + } +#endif TCP_name(addr, l, sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port); @@ -107,6 +116,16 @@ vca_handover(struct sess *sp, int bad) WRK_QueueSession(sp); } +void +vca_handfirst(struct sess *sp) +{ + sp->step = STP_FIRST; + VSL_stats->client_req++; + sp->xid = xids++; + VSL(SLT_ReqStart, sp->fd, "XID %u", sp->xid); + WRK_QueueSession(sp); +} + /*--------------------------------------------------------------------*/ void diff --git a/varnish-cache/bin/varnishd/cache_acceptor.h b/varnish-cache/bin/varnishd/cache_acceptor.h index c78ab2c7..5746f4f4 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.h +++ b/varnish-cache/bin/varnishd/cache_acceptor.h @@ -28,4 +28,5 @@ extern struct acceptor acceptor_poll; /* vca_acceptor.c */ struct sess *vca_accept_sess(int fd); void vca_handover(struct sess *sp, int bad); +void vca_handfirst(struct sess *sp); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index cf6d4320..b4468a48 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -235,6 +235,36 @@ cnt_fetch(struct sess *sp) INCOMPL(); } +static int +cnt_first(struct sess *sp) +{ + int i; + + for (;;) { + i = http_RecvSome(sp->fd, sp->http); + switch (i) { + case -1: + continue; + case 0: + sp->step = STP_RECV; + return (0); + case 1: + vca_close_session(sp, "overflow"); + SES_Charge(sp); + vca_return_session(sp); + sp->step = STP_DONE; + return (1); + case 2: + vca_close_session(sp, "no request"); + SES_Charge(sp); + vca_return_session(sp); + sp->step = STP_DONE; + return (1); + default: + INCOMPL(); + } + } +} /*-------------------------------------------------------------------- * We had a cache hit. Ask VCL, then march off as instructed. diff --git a/varnish-cache/bin/varnishd/steps.h b/varnish-cache/bin/varnishd/steps.h index 1e2a9bd7..eff825a8 100644 --- a/varnish-cache/bin/varnishd/steps.h +++ b/varnish-cache/bin/varnishd/steps.h @@ -1,5 +1,6 @@ /* $Id$ */ +STEP(first, FIRST) STEP(recv, RECV) STEP(pipe, PIPE) STEP(pass, PASS) -- 2.39.5