Avoid calling send_extra_file_list() when we shouldn't.
[rsync/rsync.git] / io.c
diff --git a/io.c b/io.c
index da6d0a5..ce6495a 100644 (file)
--- a/io.c
+++ b/io.c
@@ -54,6 +54,7 @@ extern int checksum_seed;
 extern int protocol_version;
 extern int remove_source_files;
 extern int preserve_hard_links;
+extern BOOL extra_flist_sending_enabled;
 extern struct stats stats;
 extern struct file_list *cur_flist;
 #ifdef ICONV_OPTION
@@ -520,11 +521,15 @@ static int read_timeout(int fd, char *buf, size_t len)
                                maxfd = new_fd;
                }
 
-               if (am_sender && inc_recurse && !flist_eof && !defer_forwarding_messages && !cnt
-                && file_total - file_old_total < MAX_FILECNT_LOOKAHEAD
-                && file_total - file_old_total >= MIN_FILECNT_LOOKAHEAD)
-                       tv.tv_sec = 0;
-               else
+               if (extra_flist_sending_enabled && !defer_forwarding_messages) {
+                       if (file_total - file_old_total < MAX_FILECNT_LOOKAHEAD
+                        && file_total - file_old_total >= MIN_FILECNT_LOOKAHEAD)
+                               tv.tv_sec = 0;
+                       else {
+                               extra_flist_sending_enabled = False;
+                               tv.tv_sec = select_timeout;
+                       }
+               } else
                        tv.tv_sec = select_timeout;
                tv.tv_usec = 0;
 
@@ -537,9 +542,11 @@ static int read_timeout(int fd, char *buf, size_t len)
                                defer_forwarding_messages = 0;
                                exit_cleanup(RERR_SOCKETIO);
                        }
-                       if (am_sender && tv.tv_sec == 0)
+                       if (extra_flist_sending_enabled && !defer_forwarding_messages) {
+                               extra_flist_sending_enabled = False;
                                send_extra_file_list(sock_f_out, -1);
-                       else
+                               extra_flist_sending_enabled = !flist_eof;
+                       } else
                                check_timeout();
                        continue;
                }
@@ -629,13 +636,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 +1033,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 +1474,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);