[master] da6de540b In pass mode, postpone close if response is outstanding

Poul-Henning Kamp phk at FreeBSD.org
Wed Oct 27 09:26:06 UTC 2021


commit da6de540b592411aa3f0e19a3d9b12ce30af879d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Oct 27 09:24:43 2021 +0000

    In pass mode, postpone close if response is outstanding

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 306564416..83b86f7f1 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -341,6 +341,7 @@ pass(int sock)
 	char buf[1024];
 	int i;
 	ssize_t n;
+	int busy = 0;
 
 	fds[0].fd = sock;
 	fds[0].events = POLLIN;
@@ -352,16 +353,22 @@ pass(int sock)
 			continue;
 		}
 		assert(i > 0);
-		if (fds[0].revents & POLLIN)
+		if (fds[0].revents & POLLIN) {
 			(void)pass_answer(fds[0].fd, pass_script);
+			busy = 0;
+			if (fds[1].fd < 0)
+				RL_EXIT(0);
+		}
 		if (fds[1].revents & POLLIN || fds[1].revents & POLLHUP) {
 			n = read(fds[1].fd, buf, sizeof buf - 1);
 			if (n == 0) {
-				AZ(shutdown(sock, SHUT_WR));
+				if (!busy)
+					RL_EXIT(0);
 				fds[1].fd = -1;
 			} else if (n < 0) {
 				RL_EXIT(0);
 			} else {
+				busy = 1;
 				buf[n] = '\0';
 				cli_write(sock, buf);
 			}


More information about the varnish-commit mailing list