[experimental-ims] 610d3cb I have no idea how I ended up incrementting the fail counter by the size of the request, probably sleep copy&paste ?

Poul-Henning Kamp phk at FreeBSD.org
Thu Dec 18 10:27:52 CET 2014


commit 610d3cbee4fd6b1e2ca6c84ef385beae07f56144
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 30 15:52:55 2012 +0000

    I have no idea how I ended up incrementting the fail counter by the
    size of the request, probably sleep copy&paste ?
    
    Fixed	#1175
    Submitted by:	martin

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



More information about the varnish-commit mailing list