r4650 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Thu Apr 8 18:19:22 CEST 2010


Author: phk
Date: 2010-04-08 18:19:22 +0200 (Thu, 08 Apr 2010)
New Revision: 4650

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_esi.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Add a HTTP_Copy() function and use it for the "rollback" copy of req.*

This was forgotten when number of HTTP headers was made dynamic.

The lack of this function may have made ESI includes weird.

Should be merged to 2.1



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2010-04-08 10:35:22 UTC (rev 4649)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2010-04-08 16:19:22 UTC (rev 4650)
@@ -135,6 +135,7 @@
 	HTTP_Obj = 3
 };
 
+/* NB: remember to update http_Copy() if you add fields */
 struct http {
 	unsigned		magic;
 #define HTTP_MAGIC		0x6428b5c9
@@ -514,6 +515,7 @@
 
 /* cache_http.c */
 unsigned HTTP_estimate(unsigned nhttp);
+void HTTP_Copy(struct http *to, const struct http * const fm);
 struct http *HTTP_create(void *p, unsigned nhttp);
 const char *http_StatusMessage(unsigned);
 unsigned http_EstimateWS(const struct http *fm, unsigned how, unsigned *nhd);

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2010-04-08 10:35:22 UTC (rev 4649)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2010-04-08 16:19:22 UTC (rev 4650)
@@ -1132,7 +1132,7 @@
 	sp->ws_req = WS_Snapshot(sp->ws);
 
 	/* Catch original request, before modification */
-	*sp->http0 = *sp->http;
+	HTTP_Copy(sp->http0, sp->http);
 
 	if (done != 0) {
 		sp->err_code = done;

Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_esi.c	2010-04-08 10:35:22 UTC (rev 4649)
+++ trunk/varnish-cache/bin/varnishd/cache_esi.c	2010-04-08 16:19:22 UTC (rev 4650)
@@ -896,7 +896,7 @@
 			http_save = *sp->http;
 
 		/* Reset request to status before we started messing with it */
-		*sp->http = *sp->http0;
+		HTTP_Copy(sp->http, sp->http0);
 
 		/* Take a workspace snapshot */
 		ws_wm = WS_Snapshot(sp->ws);

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2010-04-08 10:35:22 UTC (rev 4649)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2010-04-08 16:19:22 UTC (rev 4650)
@@ -894,6 +894,22 @@
 
 /*--------------------------------------------------------------------*/
 
+void
+HTTP_Copy(struct http *to, const struct http * const fm)
+{
+
+	to->conds = fm->conds;
+	to->logtag = fm->logtag;
+	to->status = fm->status;
+	to->protover = fm->protover;
+	to->nhd = fm->nhd;
+	assert(fm->nhd <= to->shd);
+	memcpy(to->hd, fm->hd, fm->nhd * sizeof *to->hd);
+	memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->hdf);
+}
+
+/*--------------------------------------------------------------------*/
+
 unsigned
 http_Write(struct worker *w, const struct http *hp, int resp)
 {

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-04-08 10:35:22 UTC (rev 4649)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-04-08 16:19:22 UTC (rev 4650)
@@ -867,7 +867,7 @@
 VRT_Rollback(struct sess *sp)
 {
 
-	*sp->http = *sp->http0;
+	HTTP_Copy(sp->http, sp->http0);
 	WS_Reset(sp->ws, sp->ws_req);
 }
 




More information about the varnish-commit mailing list