From: des Date: Fri, 20 Jul 2007 08:39:45 +0000 (+0000) Subject: Paranoia. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc1113e46941edebd41c77277fbc5741c0af0735;p=varnish Paranoia. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1728 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 2ac2450f..b8575c0c 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -46,7 +46,7 @@ static void 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 @@ rdf(struct pollfd *fds, int idx) 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; } } }