[master] e8b3d50 Don't wait for a CLI connection if the varnishd process closed the debug pipe.

Poul-Henning Kamp phk at varnish-cache.org
Tue Feb 1 13:13:57 CET 2011


commit e8b3d50e4878016241868a3266843de4e93cbf27
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 1 12:13:32 2011 +0000

    Don't wait for a CLI connection if the varnishd process closed the
    debug pipe.

diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 56c6f4d..7e59311 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -237,7 +237,7 @@ varnish_launch(struct varnish *v)
 	int i, nfd, nap;
 	struct vss_addr **ap;
 	char abuf[128], pbuf[128];
-	struct pollfd fd;
+	struct pollfd fd[2];
 	enum cli_status_e u;
 	char *r;
 
@@ -301,13 +301,25 @@ varnish_launch(struct varnish *v)
 	AZ(pthread_create(&v->tp, NULL, varnish_thread, v));
 
 	/* Wait for the varnish to call home */
-	fd.fd = v->cli_fd;
-	fd.events = POLLIN;
-	i = poll(&fd, 1, 10000);
-	if (i != 1) {
+	fd[0].fd = v->cli_fd;
+	fd[0].events = POLLIN;
+	fd[1].fd = v->fds[0];
+	fd[1].events = POLLOUT;
+	i = poll(fd, 2, 10000);
+	vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x",
+	    i, fd[0].revents, fd[1].revents);
+	if (i == 0) {
 		vtc_log(v->vl, 0, "FAIL timeout waiting for CLI connection");
 		return;
 	}
+	if (fd[1].revents & POLLHUP) {
+		vtc_log(v->vl, 0, "FAIL debug pipe closed");
+		return;
+	}
+	if (!(fd[0].revents & POLLIN)) {
+		vtc_log(v->vl, 0, "FAIL CLI connection wait failure");
+		return;
+	}
 	nfd = accept(v->cli_fd, NULL, NULL);
 	if (nfd < 0) {
 		vtc_log(v->vl, 0, "FAIL no CLI connection accepted");



More information about the varnish-commit mailing list