]> err.no Git - varnish/commitdiff
It's cheaper to pipe than to pass, so if the client indicates
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 08:15:46 +0000 (08:15 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 08:15:46 +0000 (08:15 +0000)
"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

index 34e769fb3b240b963f71c3d7538050ec75f35250..22d6e46a583f8ed67f0c81d351d48360f6f15421 100644 (file)
@@ -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));