[master] 2679bb6 Allow return(abandon) in vcl_backend_error{}

Poul-Henning Kamp phk at FreeBSD.org
Fri May 15 15:59:36 CEST 2015


commit 2679bb6db2f30b29f31da629927c7e0b243ea7d3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri May 15 13:58:43 2015 +0000

    Allow return(abandon) in vcl_backend_error{}
    
    Submitted by:	fgs

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index b29eb25..b52354a 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -800,14 +800,16 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 
 	AZ(VSB_finish(synth_body));
 
-	if (wrk->handling == VCL_RET_RETRY) {
+	if (wrk->handling == VCL_RET_RETRY ||
+	    wrk->handling == VCL_RET_ABANDON) {
 		VSB_delete(synth_body);
 
 		bo->doclose = SC_RESP_CLOSE;
 		if (bo->director_state != DIR_S_NULL)
 			VDI_Finish(bo->wrk, bo);
 
-		if (bo->retries++ < cache_param->max_retries)
+		if (wrk->handling == VCL_RET_RETRY &&
+		    bo->retries++ < cache_param->max_retries)
 			return (F_STP_RETRY);
 
 		return (F_STP_FAIL);
diff --git a/bin/varnishtest/tests/b00038.vtc b/bin/varnishtest/tests/b00038.vtc
index 963dc48..b963b4f 100644
--- a/bin/varnishtest/tests/b00038.vtc
+++ b/bin/varnishtest/tests/b00038.vtc
@@ -1,18 +1,37 @@
-varnishtest "vcl_backend_fetch abandon"
+varnishtest "Test abandon from vcl_backend_xxx"
 
 server s1 {
 	rxreq
+	expect req.url == "/bar"
 	txresp
 } -start
 
-varnish v1 -vcl+backend {
+varnish v1 -arg "-pfirst_byte_timeout=0.1" -vcl+backend {
 	sub vcl_backend_fetch {
+		if (bereq.url == "/foo") {
+			return (abandon);
+		}
+	}
+	sub vcl_backend_response {
+		if (bereq.url == "/bar") {
+			return (abandon);
+		}
+	}
+	sub vcl_backend_error {
 		return (abandon);
 	}
 } -start
 
 client c1 {
-	txreq
+	txreq -url /foo
+	rxresp
+	expect resp.status == 503
+
+	txreq -url /bar
+	rxresp
+	expect resp.status == 503
+
+	txreq -url /baz
 	rxresp
 	expect resp.status == 503
 } -run
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 27b3e17..f342012 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -132,7 +132,7 @@ returns =(
 	),
 	('backend_error',
 		"B",
-		('deliver', 'retry')
+		('deliver', 'retry', 'abandon')
 	),
 
 	###############################################################



More information about the varnish-commit mailing list