]> err.no Git - varnish/commitdiff
Move bereq backwards into cache_center.c for Fetch cases (Pass, Miss)
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 20:59:27 +0000 (20:59 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 20:59:27 +0000 (20:59 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1634 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_fetch.c

index d299e85f59b49205f9230ec953a4a2a2490088bd..221ad70f45de5257f0211a6c30614f5e8b965e58 100644 (file)
@@ -318,6 +318,7 @@ struct sess {
        TAILQ_ENTRY(sess)       list;
 
        struct backend          *backend;
+       struct bereq            *bereq;
        struct object           *obj;
        struct VCL_conf         *vcl;
 
index 0f92fd8ab70e5e8ee2afb72971a2f6b83c2eabf7..c5912e55742a609db4e2a3eee7e3621e04ca3d40 100644 (file)
@@ -278,8 +278,32 @@ DOT errfetch [label="ERROR",shape=plaintext]
 static int
 cnt_fetch(struct sess *sp)
 {
+       struct bereq *bereq;
+       struct http *hp;
+       char *b;
+       int i;
+
+       bereq = vbe_new_bereq();
+       AN(bereq);
+       hp = bereq->http;
+       hp->logtag = HTTP_Tx;
+
+       http_GetReq(sp->wrk, sp->fd, hp, sp->http);
+       http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_FETCH);
+       http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
+       http_PrintfHeader(sp->wrk, sp->fd, hp,
+           "X-Forwarded-for: %s", sp->addr);
+       if (!http_GetHdr(hp, H_Host, &b)) {
+               http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
+                   sp->backend->hostname);
+       }
+       sp->bereq = bereq;
+
+       i = Fetch(sp);
+       vbe_free_bereq(sp->bereq);
+       sp->bereq = NULL;
 
-       if (Fetch(sp)) {
+       if (i) {
                SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
        } else {
                RFC2616_cache_policy(sp, &sp->obj->http);       /* XXX -> VCL */
index d4dd3f4d1bc9ebacc9591b354ecee62ef1409375..12445d56ff743bf4dcb5612836977f4caf9ae911 100644 (file)
@@ -270,32 +270,19 @@ Fetch(struct sess *sp)
        CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
        assert(sp->obj->busy != 0);
        w = sp->wrk;
+       bereq = sp->bereq;
+       hp = bereq->http;
 
        sp->obj->xid = sp->xid;
 
        vc = VBE_GetFd(sp);
        if (vc == NULL)
                return (1);
-
-       bereq = vbe_new_bereq();
-       AN(bereq);
-       hp = bereq->http;
-       hp->logtag = HTTP_Tx;
-
-       http_GetReq(w, vc->fd, hp, sp->http);
-       http_FilterHeader(w, vc->fd, hp, sp->http, HTTPH_R_FETCH);
-       http_PrintfHeader(w, vc->fd, hp, "X-Varnish: %u", sp->xid);
-       http_PrintfHeader(w, vc->fd, hp,
-           "X-Forwarded-for: %s", sp->addr);
-       if (!http_GetHdr(hp, H_Host, &b)) {
-               http_PrintfHeader(w, vc->fd, hp, "Host: %s",
-                   sp->backend->hostname);
-       }
-
        WRK_Reset(w, &vc->fd);
        http_Write(w, hp, 0);
        if (WRK_Flush(w)) {
                /* XXX: cleanup */
+               
                return (1);
        }
 
@@ -377,7 +364,6 @@ Fetch(struct sess *sp)
                VBE_ClosedFd(sp->wrk, vc, 0);
        else
                VBE_RecycleFd(sp->wrk, vc);
-       vbe_free_bereq(bereq);
 
        return (0);
 }