[master] d92ca5087 varnishd: always shutdown both ends to a backend

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Mar 1 14:07:04 UTC 2024


commit d92ca50874db7397345601cb2d16b425a9df7f6f
Author: Asad Sajjad Ahmed <asadsa at varnish-software.com>
Date:   Mon Feb 19 13:01:41 2024 +0100

    varnishd: always shutdown both ends to a backend
    
    Signed-off-by: Asad Sajjad Ahmed <asadsa at varnish-software.com>

diff --git a/bin/varnishd/cache/cache_conn_pool.c b/bin/varnishd/cache/cache_conn_pool.c
index 131fc20da..c879dd669 100644
--- a/bin/varnishd/cache/cache_conn_pool.c
+++ b/bin/varnishd/cache/cache_conn_pool.c
@@ -231,7 +231,7 @@ VCP_Rel(struct conn_pool **cpp)
 		cp->n_conn--;
 		assert(pfd->state == PFD_STATE_AVAIL);
 		pfd->state = PFD_STATE_CLEANUP;
-		(void)shutdown(pfd->fd, SHUT_WR);
+		(void)shutdown(pfd->fd, SHUT_RDWR);
 		cp->n_kill++;
 	}
 	while (cp->n_kill) {
diff --git a/bin/varnishtest/tests/b00083.vtc b/bin/varnishtest/tests/b00083.vtc
new file mode 100644
index 000000000..f648c30e1
--- /dev/null
+++ b/bin/varnishtest/tests/b00083.vtc
@@ -0,0 +1,47 @@
+varnishtest "VCP FIN-WAIT2"
+
+server s1 {
+	rxreq
+	txresp
+
+	# Leave the TCP connection open in the FIN-WAIT2 state
+	delay 1000
+} -start
+
+server s2 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl {
+	backend s1 {
+	    .host = "${s1_sock}";
+	}
+} -start
+
+# The waiter depend on the backend_idle_timeout for when to give up and
+# close the connection, so bump it up a bit.
+varnish v1 -cliok "param.set backend_idle_timeout 120"
+
+# The shutdown is done on the CLI thread, and it blocks until the waiter has
+# killed the connection. So bump cli_timeout up as well
+varnish v1 -cliok "param.set cli_timeout 120"
+
+client c1 {
+	txreq -url "/"
+	rxresp
+} -run
+
+varnish v1 -vcl {
+	backend s2 {
+	    .host = "${s2_sock}";
+	}
+}
+
+varnish v1 -cliok "vcl.use vcl2"
+varnish v1 -cliok "vcl.discard vcl1"
+
+varnish v1 -expect n_backend == 1
+varnish v1 -expect backend_conn == 1
+varnish v1 -expect backend_reuse == 0
+varnish v1 -expect backend_recycle == 1


More information about the varnish-commit mailing list