[4.1] 11c0008 invalidate the cli_fd of dead varnishds

Lasse Karstensen lkarsten at varnish-software.com
Tue Jun 14 12:00:16 CEST 2016


commit 11c00080cfe0b610cbecb4ab861f089bc803becc
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue May 17 14:38:04 2016 +0200

    invalidate the cli_fd of dead varnishds
    
    In particular, this avoids a later backend.list attempt on a file descriptor
    to a dead process and, consequently, avoids a long delay in varnishtest
    when varnishd cant be started (for instance, because it is not in PATH).

diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 1ff780f..8f52886 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -466,18 +466,26 @@ varnish_launch(struct varnish *v)
 	    i, fd[0].revents, fd[1].revents);
 	if (i == 0) {
 		vtc_log(v->vl, 0, "FAIL timeout waiting for CLI connection");
+		AZ(close(v->cli_fd));
+		v->cli_fd = -1;
 		return;
 	}
 	if (fd[1].revents & POLLHUP) {
 		vtc_log(v->vl, 0, "FAIL debug pipe closed");
+		AZ(close(v->cli_fd));
+		v->cli_fd = -1;
 		return;
 	}
 	if (!(fd[0].revents & POLLIN)) {
 		vtc_log(v->vl, 0, "FAIL CLI connection wait failure");
+		AZ(close(v->cli_fd));
+		v->cli_fd = -1;
 		return;
 	}
 	nfd = accept(v->cli_fd, NULL, NULL);
 	if (nfd < 0) {
+		AZ(close(v->cli_fd));
+		v->cli_fd = -1;
 		vtc_log(v->vl, 0, "FAIL no CLI connection accepted");
 		return;
 	}



More information about the varnish-commit mailing list