[PATCH 2/2] -smalloc counter c_fail should be incremented once only on errors.

Martin Blix Grydeland martin at varnish-software.com
Tue Jul 24 14:44:52 CEST 2012


Fixes: #1175
---
 bin/varnishd/storage/storage_malloc.c |    2 +-
 bin/varnishtest/tests/r01175.vtc      |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01175.vtc

diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c
index 0470093..88cb948 100644
--- a/bin/varnishd/storage/storage_malloc.c
+++ b/bin/varnishd/storage/storage_malloc.c
@@ -67,7 +67,7 @@ sma_alloc(struct stevedore *st, size_t size)
 	Lck_Lock(&sma_sc->sma_mtx);
 	sma_sc->stats->c_req++;
 	if (sma_sc->sma_alloc + size > sma_sc->sma_max) {
-		sma_sc->stats->c_fail += size;
+		sma_sc->stats->c_fail++;
 		size = 0;
 	} else {
 		sma_sc->sma_alloc += size;
diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc
new file mode 100644
index 0000000..739c56a
--- /dev/null
+++ b/bin/varnishtest/tests/r01175.vtc
@@ -0,0 +1,20 @@
+varnishtest "#1175 - -smalloc c_fail incremented by bytes"
+
+server s1 {
+	rxreq
+	txresp -nolen -hdr "Content-Length: 1048576"
+} -start
+
+varnish v1 -storage "-s test=malloc,1M" -vcl+backend {
+	sub vcl_fetch {
+		set beresp.storage = "test";
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 503
+} -run
+
+varnish v1 -expect SMA.test.c_fail < 5
-- 
1.7.9.5




More information about the varnish-dev mailing list