r727 - trunk/varnish-cache/lib/libvarnish
phk at projects.linpro.no
phk at projects.linpro.no
Mon Aug 7 18:05:21 CEST 2006
Author: phk
Date: 2006-08-07 18:05:21 +0200 (Mon, 07 Aug 2006)
New Revision: 727
Modified:
trunk/varnish-cache/lib/libvarnish/cli_common.c
Log:
Handle read errors on the cli pipes.
Modified: trunk/varnish-cache/lib/libvarnish/cli_common.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli_common.c 2006-08-07 15:54:51 UTC (rev 726)
+++ trunk/varnish-cache/lib/libvarnish/cli_common.c 2006-08-07 16:05:21 UTC (rev 727)
@@ -73,9 +73,9 @@
}
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;
pfd.fd = fd;
@@ -85,7 +85,17 @@
errno = ETIMEDOUT;
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
@@ -97,9 +107,12 @@
char *p;
i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
- if (i < 0)
- return (i);
- assert(i == CLI_LINE0_LEN); /* XXX: handle */
+ if (i != CLI_LINE0_LEN) {
+ if (status != NULL)
+ *status = CLIS_COMMS;
+ return (1);
+ }
+ assert(i == CLI_LINE0_LEN);
assert(res[3] == ' ');
assert(res[CLI_LINE0_LEN - 1] == '\n');
j = sscanf(res, "%u %u\n", &u, &v);
More information about the varnish-commit
mailing list