From: phk Date: Tue, 3 Jul 2007 20:49:42 +0000 (+0000) Subject: Move VCL_pipe_method() processing into cache_center.c where it belongs. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e246332253b6d14230a5b4cf795034ac6c92c010;p=varnish Move VCL_pipe_method() processing into cache_center.c where it belongs. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1633 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index cbf5c2e4..d299e85f 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -438,7 +438,7 @@ void http_CopyHome(struct http *hp); #undef HTTPH /* cache_pipe.c */ -void PipeSession(struct sess *sp); +void PipeSession(struct sess *sp, struct bereq *bereq); /* cache_pool.c */ void WRK_Init(void); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 5f952c37..0f92fd8a 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -600,9 +600,34 @@ DOT err_pipe [label="ERROR",shape=plaintext] static int cnt_pipe(struct sess *sp) { + struct bereq *bereq; + struct http *hp; + char *b; sp->wrk->acct.pipe++; - PipeSession(sp); + + bereq = vbe_new_bereq(); + XXXAN(bereq); + hp = bereq->http; + hp->logtag = HTTP_Tx; + + http_CopyReq(sp->wrk, sp->fd, hp, sp->http); + http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_PIPE); + http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid); + http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Forwarded-for: %s", sp->addr); + + /* XXX: does this belong in VCL ? */ + if (!http_GetHdr(hp, H_Host, &b)) { + http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s", + sp->backend->hostname); + } + + VCL_pipe_method(sp); + + if (sp->handling == VCL_RET_ERROR) + INCOMPL(); + + PipeSession(sp, bereq); sp->step = STP_DONE; return (0); } diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 383a2533..f3244451 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -72,14 +72,12 @@ rdf(struct pollfd *fds, int idx) } void -PipeSession(struct sess *sp) +PipeSession(struct sess *sp, struct bereq *bereq) { struct vbe_conn *vc; char *b, *e; struct worker *w; struct pollfd fds[2]; - struct bereq *bereq; - struct http *hp; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -90,30 +88,8 @@ PipeSession(struct sess *sp) if (vc == NULL) return; - bereq = vbe_new_bereq(); - AN(bereq); - hp = bereq->http; - hp->logtag = HTTP_Tx; - - http_CopyReq(w, vc->fd, hp, sp->http); - http_FilterHeader(w, vc->fd, hp, sp->http, HTTPH_R_PIPE); - http_PrintfHeader(w, vc->fd, hp, "X-Varnish: %u", sp->xid); - http_PrintfHeader(w, vc->fd, hp, - "X-Forwarded-for: %s", sp->addr); - - /* XXX: does this belong in VCL ? */ - if (!http_GetHdr(hp, H_Host, &b)) { - http_PrintfHeader(w, vc->fd, hp, "Host: %s", - sp->backend->hostname); - } - - VCL_pipe_method(sp); - - if (sp->handling == VCL_RET_ERROR) - INCOMPL(); - WRK_Reset(w, &vc->fd); - http_Write(w, hp, 0); + http_Write(w, bereq->http, 0); if (http_GetTail(sp->http, 0, &b, &e) && b != e) WRK_Write(w, b, e - b); @@ -126,7 +102,6 @@ PipeSession(struct sess *sp) vbe_free_bereq(bereq); bereq = NULL; - hp = NULL; clock_gettime(CLOCK_REALTIME, &sp->t_resp);