]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
don't write more than PIPE_BUF bytes in any one write() in io.c
authorAndrew Tridgell <tridge@samba.org>
Tue, 23 Nov 1999 08:43:16 +0000 (08:43 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 23 Nov 1999 08:43:16 +0000 (08:43 +0000)
this makes sure that the write never blocks.

io.c
rsync.h

diff --git a/io.c b/io.c
index 9e2d379099104a88fb16ec687a086a1f9b2343e6..9e2a475731ad1af903bf008042a49a2fa3f601b3 100644 (file)
--- a/io.c
+++ b/io.c
@@ -361,8 +361,11 @@ static void writefd_unbuffered(int fd,char *buf,int len)
                }
 
                if (FD_ISSET(fd, &w_fds)) {
-                       int n = len-total;
-                       int ret = write(fd,buf+total,n?n:1);
+                       int ret, n = len-total;
+                       
+                       if (n > PIPE_BUF) n = PIPE_BUF;
+
+                       ret = write(fd,buf+total,n?n:1);
 
                        if (ret == -1 && errno == EINTR) {
                                continue;
diff --git a/rsync.h b/rsync.h
index 03d38dd9564cd97431c3cdc2252c05be6b4fbc2f..7bde8b2a6c97c53980cd20e8ce951151b79730c0 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 #define MAXPATHLEN 1024
 #endif
 
+#ifndef PIPE_BUF
+#define PIPE_BUF 512
+#endif
+
 #ifndef INADDR_NONE
 #define INADDR_NONE 0xffffffff
 #endif