From: phk Date: Mon, 1 May 2006 07:53:21 +0000 (+0000) Subject: Centralize "Connection: close" handling from the backend. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15d0dde838964bbf8d5f18a4984c11a05db2b8bc;p=varnish Centralize "Connection: close" handling from the backend. Loop until we have the entire chunk in chunked encoding git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@157 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 2dc7ed05..33370305 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -67,13 +67,8 @@ fetch_straight(struct worker *w, struct sess *sp, int fd, struct http *hp, char assert(i == st->len); hash->deref(sp->obj); + return (0); - if (http_GetHdr(sp->http, "Connection", &b) && - !strcasecmp(b, "close")) { - return (1); - } else { - return (0); - } } static int @@ -130,11 +125,13 @@ printf("Tail: (B)\n%#H\n", b, e - b); p += e - b; u -= e - b; } - if (u > 0) { + while (u > 0) { i = read(fd, p, u); + assert(i > 0); + u -= i; + p += i; if (0) printf("u = %u i = %d\n", u, i); - assert(i == u); } if (0) printf("Store:\n%#H\n", st->ptr, st->len); @@ -151,12 +148,7 @@ printf("Store:\n%#H\n", st->ptr, st->len); hash->deref(sp->obj); - if (http_GetHdr(sp->http, "Connection", &b) && - !strcasecmp(b, "close")) { - return (1); - } else { - return (0); - } + return (0); } /*--------------------------------------------------------------------*/ @@ -208,6 +200,9 @@ HERE(); cls = 0; } + if (http_GetHdr(hp, "Connection", &b) && !strcasecmp(b, "close")) + cls = 1; + if (cls) VBE_ClosedFd(fd_token); else