From: phk Date: Fri, 21 Jul 2006 10:44:12 +0000 (+0000) Subject: Make pipe use the new http manipulation. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11b70f22e0a1567e307ff92366497a95b0719bba;p=varnish Make pipe use the new http manipulation. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@534 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index f743a654..b017383e 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -333,7 +333,7 @@ void PassSession(struct sess *sp); void PassBody(struct worker *w, struct sess *sp); /* cache_pipe.c */ -void PipeSession(struct worker *w, struct sess *sp); +void PipeSession(struct sess *sp); /* 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 9ef84388..e6adabab 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -477,7 +477,7 @@ static int cnt_pipe(struct sess *sp) { - PipeSession(sp->wrk, sp); + PipeSession(sp); sp->step = STP_DONE; return (0); } diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index fbb46350..a807f33e 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -191,6 +191,7 @@ PassSession(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; + vc = VBE_GetFd(sp->backend, sp->xid); assert(vc != NULL); VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); @@ -214,6 +215,5 @@ PassSession(struct sess *sp) (void)event_base_loop(w->eb, 0); http_DissectResponse(hp, vc->fd); - sp->bkd_http = hp; sp->vbc = vc; } diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 66bfc1a0..ba893e94 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -45,27 +45,34 @@ rdf(int fd, short event, void *arg) } void -PipeSession(struct worker *w, struct sess *sp) +PipeSession(struct sess *sp) { - int i; struct vbe_conn *vc; struct edir e1, e2; char *b, *e; + struct worker *w; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + w = sp->wrk; vc = VBE_GetFd(sp->backend, sp->xid); assert(vc != NULL); VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); - http_BuildSbuf(vc->fd, Build_Pipe, w->sb, sp->http); - i = write(vc->fd, sbuf_data(w->sb), sbuf_len(w->sb)); - assert(i == sbuf_len(w->sb)); - if (http_GetTail(sp->http, 0, &b, &e) && b != e) { - i = write(vc->fd, b, e - b); - if (i != e - b) { - close (vc->fd); - vca_close_session(sp, "pipe"); - VBE_ClosedFd(vc); - } + http_CopyReq(vc->fd, vc->http, sp->http); + http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_PIPE); + http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid); + WRK_Reset(w, &vc->fd); + http_Write(w, vc->http, 0); + + if (http_GetTail(sp->http, 0, &b, &e) && b != e) + WRK_Write(w, b, e - b); + + if (WRK_Flush(w)) { + vca_close_session(sp, "pipe"); + VBE_ClosedFd(vc); + return; } e1.fd = vc->fd; diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 31b730e0..f3850fbc 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -50,7 +50,6 @@ WRK_Flush(struct worker *w) CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); if (*w->wfd < 0 || w->niov == 0 || w->werr) return (w->werr); -VSL(SLT_Debug, 0, "%s %d", __func__, *w->wfd); i = writev(*w->wfd, w->iov, w->niov); if (i != w->liov) w->werr++;