[PATCH 1/2] Increment bans_req counter when reloading bans that refer to req.*

Martin Blix Grydeland martin at varnish-software.com
Wed Nov 7 13:01:40 CET 2012


Fixes: #1225
---
 bin/varnishd/cache/cache_ban.c   |    4 ++-
 bin/varnishtest/tests/r01225.vtc |   62 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01225.vtc

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 48bde0e..2acfe80 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -599,8 +599,10 @@ BAN_Reload(const uint8_t *ban, unsigned len)
 		VSC_C_main->bans_dups++;
 		b2->flags |= BAN_F_GONE;
 	}
-	if (ban[BANHEAD_O_FLAGS] & BANHEAD_F_REQ)
+	if (ban[BANHEAD_O_FLAGS] & BANHEAD_F_REQ) {
 		b2->flags |= BAN_F_REQ;
+		VSC_C_main->bans_req++;
+	}
 	if (b2->flags & BAN_F_GONE)
 		VSC_C_main->bans_gone++;
 	if (b == NULL)
diff --git a/bin/varnishtest/tests/r01225.vtc b/bin/varnishtest/tests/r01225.vtc
new file mode 100644
index 0000000..a74d125
--- /dev/null
+++ b/bin/varnishtest/tests/r01225.vtc
@@ -0,0 +1,62 @@
+varnishtest "Test bans_req counter on persistent reload - #1225"
+
+shell "rm -f ${tmpdir}/_.per"
+
+server s1 {
+	rxreq 
+	txresp -hdr "Foo: foo"
+} -start
+
+varnish v1 \
+	-arg "-pfeature=+wait_silo" \
+	-storage "-spersistent,${tmpdir}/_.per,10m" \
+	-arg "-pban_lurker_sleep=0.01" \
+	-vcl+backend { } -start 
+
+varnish v1 -cliok ban.list
+
+client c1 {
+	txreq -url "/"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foo == "foo"
+} -run
+
+# Count of 1 here (magic ban only)
+varnish v1 -expect bans == 1
+varnish v1 -cliok "ban req.url == /"
+varnish v1 -cliok ban.list
+
+# Count of 2 here (our + magic ban)
+varnish v1 -expect bans == 2
+varnish v1 -expect bans_req == 1
+varnish v1 -stop
+server s1 -wait
+
+server s1 {
+	rxreq 
+	txresp -hdr "Foo: bar"
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+varnish v1 -cliok ban.list
+
+# Count of 3 here, our pluss magic bans from 2 startups
+varnish v1 -expect bans == 3
+
+client c1 {
+	txreq -url "/"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foo == "bar"
+} -run
+
+varnish v1 -cliok ban.list
+# Count of 1 here
+varnish v1 -expect bans == 1
+varnish v1 -expect bans_req == 0
+
+varnish v1 -stop
-- 
1.7.9.5




More information about the varnish-dev mailing list