Commit 50a77ab0 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Do proper non-blocking reads.

Spotted: drwilco

Fixes: #914
parent effaadab
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment