r4073 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon May 11 12:37:31 CEST 2009


Author: phk
Date: 2009-05-11 12:37:31 +0200 (Mon, 11 May 2009)
New Revision: 4073

Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_esi.c
Log:
Be much more consistent about snapshotting session workspace when
doing an esi-include.

This should reduce the pressure on session workspace from nested
ESI includes considerably.



Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-05-11 09:59:19 UTC (rev 4072)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-05-11 10:37:31 UTC (rev 4073)
@@ -1087,6 +1087,10 @@
 
 		/* XXX: Don't bother with write failures for now */
 		(void)write(sp->fd, r, strlen(r));
+		/* XXX: When we do ESI includes, this is not removed
+		 * XXX: because we use http0 as our basis.  Believed
+		 * XXX: safe, but potentially confusing.
+		 */
 		http_Unset(sp->http, H_Expect);
 	}
 

Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_esi.c	2009-05-11 09:59:19 UTC (rev 4072)
+++ trunk/varnish-cache/bin/varnishd/cache_esi.c	2009-05-11 10:37:31 UTC (rev 4073)
@@ -760,9 +760,12 @@
 	struct esi_bit *eb;
 	struct object *obj;
 	struct worker *w;
+	char *ws_wm;
+	struct http http_save;
 
 	w = sp->wrk;
 	WRW_Reserve(w, &sp->fd);
+	http_save.magic = 0;
 	VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
 		if (Tlen(eb->verbatim)) {
 			if (sp->http->protover >= 1.1)
@@ -784,8 +787,17 @@
 		sp->esis++;
 		obj = sp->obj;
 		sp->obj = NULL;
+
+		/* Save the master objects HTTP state, we may need it later */
+		if (http_save.magic == 0)
+			http_save = *sp->http;
+
+		/* Reset request to status before we started messing with it */
 		*sp->http = *sp->http0;
-		/* XXX: reset sp->ws */
+
+		/* Take a workspace snapshot */
+		ws_wm = WS_Snapshot(sp->ws);
+
 		http_SetH(sp->http, HTTP_HDR_URL, eb->include.b);
 		if (eb->host.b != NULL)  {
 			http_Unset(sp->http, H_Host);
@@ -822,10 +834,17 @@
 		assert(sp->step == STP_DONE);
 		sp->esis--;
 		sp->obj = obj;
+
+		/* Reset the workspace */
+		WS_Reset(sp->ws, ws_wm);
+
 		WRW_Reserve(sp->wrk, &sp->fd);
 		if (sp->fd < 0)
 			break;
 	}
+	/* Restore master objects HTTP state */
+	if (http_save.magic)
+		*sp->http = http_save;
 	if (sp->esis == 0 && sp->http->protover >= 1.1)
 		(void)WRW_Write(sp->wrk, "0\r\n\r\n", -1);
 	if (WRW_FlushRelease(sp->wrk))



More information about the varnish-commit mailing list