From: Wayne Davison Date: Mon, 12 Oct 2009 16:03:42 +0000 (-0700) Subject: Avoid stopping multiplexed out over the message fd. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/41000dffc1e98a2f9fb19550f2c6bfc5f6290137 Avoid stopping multiplexed out over the message fd. Use simpler multiplexed-out stopping method. Make sure we can't false-match a socket fd. --- diff --git a/io.c b/io.c index da6d0a59..11ec41bf 100644 --- a/io.c +++ b/io.c @@ -629,13 +629,13 @@ static int read_timeout(int fd, char *buf, size_t len) if (n <= 0) { if (n == 0) whine_about_eof(fd); /* Doesn't return. */ - if (errno == EINTR || errno == EWOULDBLOCK - || errno == EAGAIN) + if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN) continue; /* Don't write errors on a dead socket. */ if (fd == sock_f_in) { - io_end_multiplex_out(); + if (am_sender) + io_multiplexing_out = 0; rsyserr(FERROR_SOCKET, errno, "read error"); } else rsyserr(FERROR, errno, "read error"); @@ -1026,7 +1026,7 @@ static void read_a_msg(int fd) if (!am_generator) goto invalid_msg; if (tag == MSG_ERROR_SOCKET) - io_end_multiplex_out(); + io_multiplexing_out = 0; /* FALL THROUGH */ case MSG_INFO: case MSG_ERROR: @@ -1467,7 +1467,7 @@ static void writefd_unbuffered(int fd, const char *buf, size_t len) /* Don't try to write errors back across the stream. */ if (fd == sock_f_out) - io_end_multiplex_out(); + io_multiplexing_out = 0; /* Don't try to write errors down a failing msg pipe. */ if (am_server && fd == msg_fd_out) exit_cleanup(RERR_STREAMIO); diff --git a/main.c b/main.c index d8055cb6..ecae742a 100644 --- a/main.c +++ b/main.c @@ -63,6 +63,8 @@ extern int whole_file; extern int read_batch; extern int write_batch; extern int batch_fd; +extern int sock_f_in; +extern int sock_f_out; extern int filesfrom_fd; extern int connect_timeout; extern pid_t cleanup_child_pid; @@ -841,6 +843,7 @@ static int do_recv(int f_in, int f_out, char *local_name) close(error_pipe[0]); if (f_in != f_out) close(f_out); + sock_f_out = -1; /* we can't let two processes write to the socket at one time */ io_end_multiplex_out(); @@ -891,6 +894,7 @@ static int do_recv(int f_in, int f_out, char *local_name) close(error_pipe[1]); if (f_in != f_out) close(f_in); + sock_f_in = -1; io_start_buffering_out(f_out);