Commit 3806f9df authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Handle read errors on the cli pipes.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@727 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 8917e6cf
...@@ -73,9 +73,9 @@ cli_writeres(int fd, struct cli *cli) ...@@ -73,9 +73,9 @@ cli_writeres(int fd, struct cli *cli)
} }
static int static int
read_tmo(int fd, void *ptr, unsigned len, double tmo) read_tmo(int fd, char *ptr, unsigned len, double tmo)
{ {
int i; int i, j;
struct pollfd pfd; struct pollfd pfd;
pfd.fd = fd; pfd.fd = fd;
...@@ -85,7 +85,17 @@ read_tmo(int fd, void *ptr, unsigned len, double tmo) ...@@ -85,7 +85,17 @@ read_tmo(int fd, void *ptr, unsigned len, double tmo)
errno = ETIMEDOUT; errno = ETIMEDOUT;
return (-1); return (-1);
} }
return (read(fd, ptr, len)); for (j = 0; len > 0; ) {
i = read(fd, ptr, len);
if (i < 0)
return (i);
if (i == 0)
break;
len -= i;
ptr += i;
j += i;
}
return (j);
} }
int int
...@@ -97,9 +107,12 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo) ...@@ -97,9 +107,12 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo)
char *p; char *p;
i = read_tmo(fd, res, CLI_LINE0_LEN, tmo); i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
if (i < 0) if (i != CLI_LINE0_LEN) {
return (i); if (status != NULL)
assert(i == CLI_LINE0_LEN); /* XXX: handle */ *status = CLIS_COMMS;
return (1);
}
assert(i == CLI_LINE0_LEN);
assert(res[3] == ' '); assert(res[3] == ' ');
assert(res[CLI_LINE0_LEN - 1] == '\n'); assert(res[CLI_LINE0_LEN - 1] == '\n');
j = sscanf(res, "%u %u\n", &u, &v); j = sscanf(res, "%u %u\n", &u, &v);
......
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