[master] 50a77ab Do proper non-blocking reads.
Martin Blix Grydeland
martin at varnish-cache.org
Tue May 31 10:52:06 CEST 2011
commit 50a77ab0a92abf1e686611a0a25d241a2ecd14c0
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue May 31 10:50:30 2011 +0200
Do proper non-blocking reads.
Spotted: drwilco
Fixes: #914
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index 4fa7429..0396e2a 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -123,12 +123,12 @@ read_tmo(int fd, char *ptr, unsigned len, double tmo)
pfd.fd = fd;
pfd.events = POLLIN;
- i = poll(&pfd, 1, (int)(tmo * 1e3));
- if (i == 0) {
- errno = ETIMEDOUT;
- return (-1);
- }
for (j = 0; len > 0; ) {
+ i = poll(&pfd, 1, (int)(tmo * 1e3));
+ if (i == 0) {
+ errno = ETIMEDOUT;
+ return (-1);
+ }
i = read(fd, ptr, len);
if (i < 0)
return (i);
More information about the varnish-commit
mailing list