X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/b2999e457fd3f0e4ca90c6bcc5c06e112be72c3c..f0359dd00d60d72c4b3dec85de8e490692f6015c:/io.c diff --git a/io.c b/io.c index f948147e..6a55576d 100644 --- a/io.c +++ b/io.c @@ -159,6 +159,11 @@ static int read_timeout(int fd, char *buf, int len) continue; } + if (n == -1 && + (errno == EWOULDBLOCK || errno == EAGAIN)) { + continue; + } + if (n == 0) { if (eof_error) { @@ -364,12 +369,17 @@ static void writefd_unbuffered(int fd,char *buf,int len) if (FD_ISSET(fd, &w_fds)) { int ret, n = len-total; - ret = write(fd,buf+total,n?n:1); + ret = write(fd,buf+total,n); if (ret == -1 && errno == EINTR) { continue; } + if (ret == -1 && + (errno == EWOULDBLOCK || errno == EAGAIN)) { + continue; + } + if (ret <= 0) { rprintf(FERROR,"erroring writing %d bytes - exiting\n", len); exit_cleanup(RERR_STREAMIO); @@ -407,8 +417,8 @@ static void mplex_write(int fd, enum logcode code, char *buf, int len) SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len); - if (n > (sizeof(buf)-4)) { - n = sizeof(buf)-4; + if (n > (sizeof(buffer)-4)) { + n = sizeof(buffer)-4; } memcpy(&buffer[4], buf, n); @@ -417,7 +427,9 @@ static void mplex_write(int fd, enum logcode code, char *buf, int len) len -= n; buf += n; - writefd_unbuffered(fd, buf, len); + if (len) { + writefd_unbuffered(fd, buf, len); + } } @@ -597,3 +609,4 @@ void io_close_input(int fd) { buffer_f_in = -1; } +