diff -C5 rsync-2.6.0/io.c rsync-2.6.0-patched/io.c *** rsync-2.6.0/io.c Fri Dec 26 17:04:01 2003 --- rsync-2.6.0-patched/io.c Fri Dec 2 23:30:26 2005 *************** *** 594,604 **** **/ static void writefd_unbuffered(int fd,char *buf,size_t len) { size_t total = 0; fd_set w_fds, r_fds; ! int fd_count, count; struct timeval tv; err_list_push(); no_flush++; --- 594,604 ---- **/ static void writefd_unbuffered(int fd,char *buf,size_t len) { size_t total = 0; fd_set w_fds, r_fds; ! int fd_count; struct timeval tv; err_list_push(); no_flush++; *************** *** 618,642 **** tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT; tv.tv_usec = 0; errno = 0; ! count = select(fd_count+1, io_error_fd != -1?&r_fds:NULL, &w_fds,NULL, &tv); ! if (count == 0) { ! check_timeout(); ! } ! if (count <= 0) { ! if (errno == EBADF) { ! exit_cleanup(RERR_SOCKETIO); } ! continue; } if (io_error_fd != -1 && FD_ISSET(io_error_fd, &r_fds)) { read_error_fd(); } --- 618,652 ---- tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT; tv.tv_usec = 0; errno = 0; ! if (io_timeout > 0 || io_error_fd != -1) ! { ! /* A timeout is possible, or there may be data on ! * the error stream. We cannot risk blocking ! * in write(), so we have to call select() to see ! * if fd is ready for writing. ! */ ! int count = select(fd_count+1, io_error_fd != -1?&r_fds:NULL, &w_fds,NULL, &tv); ! if (count == 0) { ! check_timeout(); ! } ! if (count <= 0) { ! if (errno == EBADF) { ! exit_cleanup(RERR_SOCKETIO); ! } ! continue; } ! /* count > 0, so fall through with correct values in r_fds and w_fds. */ } + /* If we didn't call select() then FD_ISSET(fd,&w_fds) is still true. */ if (io_error_fd != -1 && FD_ISSET(io_error_fd, &r_fds)) { read_error_fd(); }