[master] 4ea9641 A zero timeout in the VCLI functions should mean "infinity".

Poul-Henning Kamp phk at varnish-cache.org
Thu Jun 2 23:31:18 CEST 2011


commit 4ea9641f17a97d8bfec5c7838b701188740c9288
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 2 21:30:42 2011 +0000

    A zero timeout in the VCLI functions should mean "infinity".
    
    This fixes "varnishadm -t 0"

diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index ed7837e..3b7a0aa 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -118,13 +118,17 @@ VCLI_WriteResult(int fd, const struct cli *cli)
 static int
 read_tmo(int fd, char *ptr, unsigned len, double tmo)
 {
-	int i, j;
+	int i, j, to;
 	struct pollfd pfd;
 
+	if (tmo > 0) 
+		to = tmo * 1e3;
+	else
+		to = -1;
 	pfd.fd = fd;
 	pfd.events = POLLIN;
 	for (j = 0; len > 0; ) {
-		i = poll(&pfd, 1, (int)(tmo * 1e3));
+		i = poll(&pfd, 1, to);
 		if (i == 0) {
 			errno = ETIMEDOUT;
 			return (-1);



More information about the varnish-commit mailing list