[master] 58fefad06 Emit minimal 500 response if vcl_synth{} fails.

Poul-Henning Kamp phk at FreeBSD.org
Wed Aug 25 07:03:06 UTC 2021


commit 58fefad0697b1ead28dfe6ac4bc9e77f8d00ccdf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Aug 25 07:00:10 2021 +0000

    Emit minimal 500 response if vcl_synth{} fails.
    
    With the synth->filters koncept out of the picture this becomes
    possible.
    
    Fixes: #3441

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 683b08135..f584f63fa 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -329,7 +329,9 @@ cnt_synth(struct worker *wrk, struct req *req)
 
 	if (wrk->handling == VCL_RET_FAIL) {
 		VSB_destroy(&synth_body);
-		req->doclose = SC_VCL_FAILURE;
+		(void)VRB_Ignore(req);
+		(void)req->transport->minimal_response(req, 500);
+		req->doclose = SC_VCL_FAILURE; // XXX: Not necessary any more ?
 		VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
 		http_Teardown(req->resp);
 		return (REQ_FSM_DONE);
diff --git a/bin/varnishtest/tests/r01576.vtc b/bin/varnishtest/tests/r01576.vtc
index e866fb145..617b6df6f 100644
--- a/bin/varnishtest/tests/r01576.vtc
+++ b/bin/varnishtest/tests/r01576.vtc
@@ -47,6 +47,8 @@ logexpect l1 -v v1 {
 # This should fail with default params and JIT/no-JIT
 client c1 {
 	txreq -url "/${string,repeat,8192,AB}"
+	rxresp
+	expect resp.status == 500
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/r02339.vtc b/bin/varnishtest/tests/r02339.vtc
index a90479a6a..11f84fb27 100644
--- a/bin/varnishtest/tests/r02339.vtc
+++ b/bin/varnishtest/tests/r02339.vtc
@@ -154,6 +154,8 @@ client c1 {
 
 client c1 {
 	txreq -url synth
+	rxresp
+	expect resp.status == 500
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/r02488.vtc b/bin/varnishtest/tests/r02488.vtc
index 11844a60b..d4c0bb069 100644
--- a/bin/varnishtest/tests/r02488.vtc
+++ b/bin/varnishtest/tests/r02488.vtc
@@ -35,6 +35,8 @@ client c1 {
 	expect resp.http.bar == "bar"
 
 	txreq -url "/empty"
+	rxresp
+	expect resp.status == 500
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc
index 8b8453b32..8f5ffd606 100644
--- a/bin/varnishtest/tests/v00051.vtc
+++ b/bin/varnishtest/tests/v00051.vtc
@@ -150,6 +150,8 @@ logexpect l1007 -v v1 -g raw {
 
 client c1 {
 	txreq -hdr "foo: synth"
+	rxresp
+	expect resp.status == 500
 	expect_close
 } -run
 


More information about the varnish-commit mailing list