From: phk Date: Tue, 3 Jul 2007 08:50:34 +0000 (+0000) Subject: Convert pipe mode to use the bereq in struct worker. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb4b34bea166c806c41b44268e16b946beab417a;p=varnish Convert pipe mode to use the bereq in struct worker. (See architect notes on wiki for reasoning) git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1622 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index abf11e5f..c6ca2051 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -165,9 +165,14 @@ struct worker { struct VCL_conf *vcl; struct srcaddr *srcaddr; struct acct acct; - unsigned char wlog[WLOGSPACE]; + + /* Backend connection space */ + struct http bereq[1]; + struct http beresp[1]; + unsigned char *wlp, *wle; unsigned wlr; + unsigned char wlog[WLOGSPACE]; }; struct workreq { diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 23af9c00..01c4d42e 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -78,6 +78,7 @@ PipeSession(struct sess *sp) char *b, *e; struct worker *w; struct pollfd fds[2]; + char wsspc[8192]; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -87,19 +88,29 @@ PipeSession(struct sess *sp) vc = VBE_GetFd(sp); if (vc == NULL) return; - vc->bereq->logtag = HTTP_Tx; + w->bereq->logtag = HTTP_Tx; - http_CopyReq(w, vc->fd, vc->bereq, sp->http); - http_FilterHeader(w, vc->fd, vc->bereq, sp->http, HTTPH_R_PIPE); - http_PrintfHeader(w, vc->fd, vc->bereq, "X-Varnish: %u", sp->xid); - http_PrintfHeader(w, vc->fd, vc->bereq, + http_Setup(w->bereq, wsspc, sizeof wsspc); + + http_CopyReq(w, vc->fd, w->bereq, sp->http); + http_FilterHeader(w, vc->fd, w->bereq, sp->http, HTTPH_R_PIPE); + http_PrintfHeader(w, vc->fd, w->bereq, "X-Varnish: %u", sp->xid); + http_PrintfHeader(w, vc->fd, w->bereq, "X-Forwarded-for: %s", sp->addr); - if (!http_GetHdr(vc->bereq, H_Host, &b)) { - http_PrintfHeader(w, vc->fd, vc->bereq, "Host: %s", + + /* XXX: does this belong in VCL ? */ + if (!http_GetHdr(w->bereq, H_Host, &b)) { + http_PrintfHeader(w, vc->fd, w->bereq, "Host: %s", sp->backend->hostname); } + + VCL_pipe_method(sp); + + if (sp->handling == VCL_RET_ERROR) + INCOMPL(); + WRK_Reset(w, &vc->fd); - http_Write(w, vc->bereq, 0); + http_Write(w, w->bereq, 0); if (http_GetTail(sp->http, 0, &b, &e) && b != e) WRK_Write(w, b, e - b);