X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/1f5c6343e6a3d55689073f60e71fd56cab42f89d..5d1e1dcf4b9d4d9e0308d3e7f7036b4e5191e323:/io.c diff --git a/io.c b/io.c index 9e2d3790..4fd1a138 100644 --- a/io.c +++ b/io.c @@ -112,6 +112,7 @@ static int read_timeout(int fd, char *buf, int len) continue; } + if (n == 0) { if (eof_error) { rprintf(FERROR,"unexpected EOF in read_timeout\n"); @@ -119,6 +120,9 @@ static int read_timeout(int fd, char *buf, int len) exit_cleanup(RERR_STREAMIO); } + /* this prevents us trying to write errors on a dead socket */ + io_multiplexing_out = 0; + rprintf(FERROR,"read error: %s\n", strerror(errno)); exit_cleanup(RERR_STREAMIO); } @@ -361,8 +365,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;