r4048 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Mon May 4 10:05:29 CEST 2009


Author: phk
Date: 2009-05-04 10:05:29 +0200 (Mon, 04 May 2009)
New Revision: 4048

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Fix a parse error in VCL:purge() string version.

Fixes #502



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-05-04 07:43:16 UTC (rev 4047)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-05-04 08:05:29 UTC (rev 4048)
@@ -133,7 +133,9 @@
 	return (p);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * XXX: Optimize the single element case ?
+ */
 
 /*lint -e{818} ap,hp could be const */
 static char *
@@ -918,20 +920,25 @@
 	}
 	b = BAN_New();
 	good = 0;
-	for (i = 1; ; i += 3) {
-		a1 = av[i];
+	for (i = 1; ;) {
+		a1 = av[i++];
 		if (a1 == NULL)
 			break;
 		good = 0;
-		a2 = av[i + 1];
+		a2 = av[i++];
 		if (a2 == NULL)
 			break;
-		a3 = av[i + 2];
+		a3 = av[i++];
 		if (a3 == NULL)
 			break;
 		if (BAN_AddTest(NULL, b, a1, a2, a3))
 			break;
 		good = 1;
+		if (av[i] == NULL)
+			break;
+		good = 0;
+		if (strcmp(av[i++], "&&"))
+			break;
 	}
 	if (!good) 
 		/* XXX: report error how ? */

Added: trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc	2009-05-04 08:05:29 UTC (rev 4048)
@@ -0,0 +1,30 @@
+# $Id$
+
+test "multi element purge"
+
+server s1 {
+	rxreq
+	txresp -hdr "foo: bar1" -body "1"
+	rxreq
+	txresp -hdr "foo: bar2" -body "22"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		purge("req.url == / && obj.http.foo ~ bar1");
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.foo == "bar1"
+	txreq
+	rxresp
+	expect resp.http.foo == "bar2"
+	txreq
+	rxresp
+	expect resp.http.foo == "bar2"
+} -run
+
+varnish v1 -cliok purge.list



More information about the varnish-commit mailing list