Commit 9ab52cf5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

This is getting too longhaired: Give backend connections another

http header which we can use to build the object headers in.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@585 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent aefb2537
......@@ -133,6 +133,8 @@ struct vbe_conn {
struct event ev;
int inuse;
struct http *http;
struct http *http2;
struct http http_mem[2];
};
/* Storage -----------------------------------------------------------*/
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment