[master] bf36a1c Fix the length recorded for truncated bans (it should be the length of the header, not 0).

Martin Blix Grydeland martin at varnish-cache.org
Fri Feb 15 14:58:00 CET 2013


commit bf36a1c58be5b8fe651e1ec6cf586feb6a671fb2
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Dec 14 16:32:39 2012 +0100

    Fix the length recorded for truncated bans (it should be the length of
    the header, not 0).
    
    Add a test case for reload of truncated bans.
    
    Fixes: #1266

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 4cf3d1b..ed4c041 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_persisted_fragmentation += ln - ban_len(b->spec);
 }
diff --git a/bin/varnishtest/tests/r01266.vtc b/bin/varnishtest/tests/r01266.vtc
new file mode 100644
index 0000000..49f2c67
--- /dev/null
+++ b/bin/varnishtest/tests/r01266.vtc
@@ -0,0 +1,41 @@
+varnishtest "#1266 - 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



More information about the varnish-commit mailing list