[master] b8a375312 vbe: Check failures to send the request earlier

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Mar 25 10:23:06 UTC 2021


commit b8a3753127ba799a6cbb20f8e651ef5a846516b3
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Wed Mar 24 17:50:23 2021 +0100

    vbe: Check failures to send the request earlier
    
    There's no point waiting for the backend to complain if we weren't able
    to properly send the backend request.
    
    Fixes #3556

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index d16ecbbd6..90c7899a5 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -300,7 +300,7 @@ vbe_dir_gethdrs(VRT_CTX, VCL_BACKEND d)
 		i = V1F_SendReq(wrk, bo, &bo->acct.bereq_hdrbytes,
 		    &bo->acct.bereq_bodybytes);
 
-		if (PFD_State(pfd) != PFD_STATE_USED) {
+		if (i == 0 && PFD_State(pfd) != PFD_STATE_USED) {
 			if (VCP_Wait(wrk, pfd, VTIM_real() +
 			    bo->htc->first_byte_timeout) != 0) {
 				bo->htc->doclose = SC_RX_TIMEOUT;
diff --git a/bin/varnishtest/tests/r03556.vtc b/bin/varnishtest/tests/r03556.vtc
new file mode 100644
index 000000000..d40afa47f
--- /dev/null
+++ b/bin/varnishtest/tests/r03556.vtc
@@ -0,0 +1,34 @@
+varnishtest "#3556"
+
+server s1 {
+	rxreq
+	txresp
+
+	non_fatal
+	rxreq
+} -start
+
+varnish v1 -cliok "param.set first_byte_timeout 10"
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq
+	rxresp
+} -run
+
+logexpect l2 -v v1 -q "ReqMethod eq POST" {
+	expect * * End
+} -start
+
+client c2 {
+	txreq -req POST \
+	    -hdr "Content-Length: 10" \
+	    -hdr "Content-Type: text/plain"
+	send incompl
+} -run
+
+logexpect l2 -wait
+
+shell -expect POST {
+	exec varnishncsa -d -n ${v1_name} -q 'Timestamp:Process[2] < 10.0'
+}


More information about the varnish-commit mailing list