r4282 - branches/2.0/varnish-cache/bin/varnishd

tfheen at projects.linpro.no tfheen at projects.linpro.no
Thu Oct 8 11:38:45 CEST 2009


Author: tfheen
Date: 2009-10-08 11:38:45 +0200 (Thu, 08 Oct 2009)
New Revision: 4282

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_center.c
   branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c
Log:
Merge r4073: 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: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-10-08 09:25:07 UTC (rev 4281)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-10-08 09:38:45 UTC (rev 4282)
@@ -935,6 +935,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: branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c	2009-10-08 09:25:07 UTC (rev 4281)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c	2009-10-08 09:38:45 UTC (rev 4282)
@@ -766,8 +766,11 @@
 {
 	struct esi_bit *eb;
 	struct object *obj;
+	char *ws_wm;
+	struct http http_save;
 
 	WRW_Reserve(sp->wrk, &sp->fd);
+	http_save.magic = 0;
 	VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
 		if (Tlen(eb->verbatim)) {
 			if (sp->http->protover >= 1.1)
@@ -789,8 +792,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);
@@ -825,10 +837,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