Mailing List Archive

r1728 - trunk/varnish-cache/bin/varnishd
Author: des
Date: 2007-07-20 10:39:45 +0200 (Fri, 20 Jul 2007)
New Revision: 1728

Modified:
trunk/varnish-cache/bin/varnishd/cache_pipe.c
Log:
Paranoia.


Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-07-20 08:38:22 UTC (rev 1727)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-07-20 08:39:45 UTC (rev 1728)
@@ -46,7 +46,7 @@
rdf(struct pollfd *fds, int idx)
{
int i, j;
- char buf[BUFSIZ];
+ char buf[BUFSIZ], *p;

i = read(fds[idx].fd, buf, sizeof buf);
if (i <= 0 || fds[1-idx].events == 0) {
@@ -55,14 +55,17 @@
shutdown(fds[idx].fd, SHUT_RD);
shutdown(fds[1-idx].fd, SHUT_WR);
fds[idx].events = 0;
- } else {
- j = write(fds[1-idx].fd, buf, i);
- if (i != j) {
+ return;
+ }
+ for (p = buf; i > 0; i -= j, p += j) {
+ j = write(fds[1-idx].fd, p, i);
+ if (j < 0) {
VSL(SLT_Debug, fds[idx].fd, "Pipe Shut write(write)");
VSL(SLT_Debug, fds[1-idx].fd, "Pipe Shut read(write)");
shutdown(fds[idx].fd, SHUT_WR);
shutdown(fds[1-idx].fd, SHUT_RD);
fds[1-idx].events = 0;
+ return;
}
}
}