From 0d01e175e54070a20add104a3f3f582eb5366c55 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 1 Aug 2006 12:38:26 +0000 Subject: [PATCH] This is getting too longhaired: Give backend connections another http header which we can use to build the object headers in. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@585 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 2 ++ varnish-cache/bin/varnishd/cache_backend.c | 20 +++++++++++++------- varnish-cache/bin/varnishd/cache_fetch.c | 14 +++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 9ee3e61b..da36a24b 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -133,6 +133,8 @@ struct vbe_conn { struct event ev; int inuse; struct http *http; + struct http *http2; + struct http http_mem[2]; }; /* Storage -----------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index d666cff0..a9d158d6 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -43,7 +43,6 @@ struct vbc_mem { unsigned magic; #define VBC_MEM_MAGIC 0x2fd7af01 struct vbe_conn vbc; - struct http http; }; /* A backend IP */ @@ -72,17 +71,24 @@ static struct vbe_conn * vbe_new_conn(void) { struct vbc_mem *vbcm; + struct vbe_conn *vbc; + unsigned char *p; - vbcm = calloc(sizeof *vbcm + heritage.mem_workspace, 1); + vbcm = calloc(sizeof *vbcm + heritage.mem_workspace * 2, 1); if (vbcm == NULL) return (NULL); vbcm->magic = VBC_MEM_MAGIC; VSL_stats->n_vbe_conn++; - vbcm->vbc.magic = VBE_CONN_MAGIC; - vbcm->vbc.vbcm = vbcm; - vbcm->vbc.http = &vbcm->http; - http_Setup(&vbcm->http, (void *)(vbcm + 1), heritage.mem_workspace); - return (&vbcm->vbc); + vbc = &vbcm->vbc; + vbc->magic = VBE_CONN_MAGIC; + vbc->vbcm = vbcm; + vbc->http = &vbc->http_mem[0]; + vbc->http2 = &vbc->http_mem[1]; + p = (void *)(vbcm + 1); + http_Setup(vbc->http, p, heritage.mem_workspace); + p += heritage.mem_workspace; + http_Setup(vbc->http2, p, heritage.mem_workspace); + return (vbc); } static void diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index c8ce3e51..0c3567e7 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -224,17 +224,7 @@ FetchBody(struct sess *sp) if (http_GetHdr(vc->http, H_Last_Modified, &b)) sp->obj->last_modified = TIM_parse(b); - hp = &sp->obj->http; - hp->s = malloc(heritage.mem_workspace); - assert(hp->s != NULL); - hp->e = hp->s + heritage.mem_workspace; - hp->v = hp->s; - /* - * We borrow the sessions workspace and http header for building the - * headers to store in the object, then copy them over there. - * The actual headers to reply with are built later on over in - * cache_response.c - */ + hp = vc->http2; http_ClrHeader(hp); hp->logtag = HTTP_Obj; http_CopyResp(sp->fd, hp, vc->http); @@ -252,6 +242,8 @@ FetchBody(struct sess *sp) } else cls = 0; + http_CopyHttp(&sp->obj->http, hp); + if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close")) cls = 1; -- 2.39.5