r585 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Aug 1 14:38:26 CEST 2006


Author: phk
Date: 2006-08-01 14:38:26 +0200 (Tue, 01 Aug 2006)
New Revision: 585

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
This is getting too longhaired:  Give backend connections another
http header which we can use to build the object headers in.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-08-01 12:04:56 UTC (rev 584)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-08-01 12:38:26 UTC (rev 585)
@@ -133,6 +133,8 @@
 	struct event		ev;
 	int			inuse;
 	struct http		*http;
+	struct http		*http2;
+	struct http		http_mem[2];
 };
 
 /* Storage -----------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-08-01 12:04:56 UTC (rev 584)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-08-01 12:38:26 UTC (rev 585)
@@ -43,7 +43,6 @@
 	unsigned		magic;
 #define VBC_MEM_MAGIC		0x2fd7af01
 	struct vbe_conn		vbc;
-	struct http		http;
 };
 
 /* A backend IP */
@@ -72,17 +71,24 @@
 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

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-08-01 12:04:56 UTC (rev 584)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-08-01 12:38:26 UTC (rev 585)
@@ -224,17 +224,7 @@
 	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 @@
 	} else
 		cls = 0;
 
+	http_CopyHttp(&sp->obj->http, hp);
+
 	if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close"))
 		cls = 1;
 




More information about the varnish-commit mailing list