[PATCH 3/5] Fix the length recorded for truncated bans (it should be the length of the header, not 0).

Martin Blix Grydeland martin at varnish-software.com
Fri Dec 14 18:41:01 CET 2012


Add a test case for reload of truncated bans.
---
 bin/varnishd/cache/cache_ban.c   |    2 +-
 bin/varnishtest/tests/p00009.vtc |   41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/p00009.vtc

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 64474a7..afff464 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -269,7 +269,7 @@ ban_mark_gone(struct ban *b)
 	b->flags |= BAN_F_GONE;
 	b->spec[BANS_FLAGS] |= BANS_FLAG_GONE;
 	VWMB();
-	vbe32enc(b->spec + BANS_LENGTH, 0);
+	vbe32enc(b->spec + BANS_LENGTH, BANS_HEAD_LEN);
 	VSC_C_main->bans_gone++;
 	VSC_C_main->bans_bytes_overhead += ln - ban_len(b->spec);
 }
diff --git a/bin/varnishtest/tests/p00009.vtc b/bin/varnishtest/tests/p00009.vtc
new file mode 100644
index 0000000..4898c43
--- /dev/null
+++ b/bin/varnishtest/tests/p00009.vtc
@@ -0,0 +1,41 @@
+varnishtest "Check persisted truncated gone bans"
+
+# Test that bans which has been gone'd, truncated and persisted works
+
+shell "rm -f ${tmpdir}/_.per1"
+
+server s1 {
+	rxreq
+	txresp -hdr "x-foo: foo"
+} -start
+
+varnish v1 \
+	-arg "-pfeature=+wait_silo" \
+	-arg "-pban_lurker_sleep=0.01" \
+	-storage "-sper1=persistent,${tmpdir}/_.per1,10m" \
+	-vcl+backend {
+	}
+varnish v1 -start
+
+# Add a ban that will (with lurker help) become a truncated gone ban last
+# in the list
+varnish v1 -cliok "ban obj.http.x-foo == bar"
+delay 1
+
+# Add an object that will point to our ban
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.x-foo == "foo"
+} -run
+
+# Force a reload
+varnish v1 -stop
+varnish v1 -start
+
+# Check that our object is still there
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.x-foo == "foo"
+} -run
-- 
1.7.10.4




More information about the varnish-dev mailing list