From eb647daffc108dd9c320bb6637685b56eb31a263 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 6 Apr 2006 08:15:46 +0000 Subject: [PATCH] It's cheaper to pipe than to pass, so if the client indicates "Connection: close", pipe instead of passing. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@122 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_pass.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 34e769fb..22d6e46a 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -26,7 +26,7 @@ static void PassReturn(struct sess *sp) { - HttpdAnalyze(sp, 2); + /* do nothing */ } /*--------------------------------------------------------------------*/ @@ -39,22 +39,30 @@ PassSession(struct worker *w, struct sess *sp) char buf[BUFSIZ]; off_t cl; + if (sp->http.H_Connection != NULL && + !strcmp(sp->http.H_Connection, "close")) { + /* + * If client wants only this one request, piping is safer + * and cheaper + */ + PipeSession(w, sp); + return; + } fd = VBE_GetFd(sp->backend, &fd_token); assert(fd != -1); HttpdBuildSbuf(0, 1, w->sb, sp); - i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb)); assert(i == sbuf_len(w->sb)); /* XXX: copy any contents */ - memset(&sp2, 0, sizeof sp2); sp2.rd_e = &w->e1; sp2.fd = fd; HttpdGetHead(&sp2, w->eb, PassReturn); event_base_loop(w->eb, 0); + HttpdAnalyze(&sp2, 2); HttpdBuildSbuf(1, 1, w->sb, &sp2); i = write(sp->fd, sbuf_data(w->sb), sbuf_len(w->sb)); -- 2.39.5