]> err.no Git - varnish/commitdiff
Paranoia.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jul 2007 08:39:45 +0000 (08:39 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jul 2007 08:39:45 +0000 (08:39 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1728 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_pipe.c

index 2ac2450fa766ed38760727467cdabab78465674b..b8575c0c8da3b0087d0e62f1056f398be01f9f45 100644 (file)
@@ -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;
                }
        }
 }