From 07b7c86c0672c38648fb715efbc0bfffd81ed182 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Nov 1999 08:43:16 +0000 Subject: [PATCH] don't write more than PIPE_BUF bytes in any one write() in io.c this makes sure that the write never blocks. --- io.c | 7 +++++-- rsync.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/io.c b/io.c index 9e2d3790..9e2a4757 100644 --- 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 03d38dd9..7bde8b2a 100644 --- a/rsync.h +++ b/rsync.h @@ -285,6 +285,10 @@ #define MAXPATHLEN 1024 #endif +#ifndef PIPE_BUF +#define PIPE_BUF 512 +#endif + #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif -- 2.34.1