--- io.c 3 Nov 2004 20:30:31 -0000 1.142 +++ io.c 20 Nov 2004 07:07:37 -0000 1.143 @@ -46,6 +46,7 @@ extern int am_server; extern int am_daemon; extern int am_sender; +extern int am_generator; extern int eol_nulls; extern int checksum_seed; extern int protocol_version; @@ -162,17 +163,17 @@ sock_f_out = f_out; } -/** Setup the fd used to receive MSG_* messages. Only needed when - * we're the generator because the sender and receiver both use the - * multiplexed I/O setup. */ +/* Setup the fd used to receive MSG_* messages. Only needed during the + * early stages of being a local sender (up through the sending of the + * file list) or when we're the generator (to fetch the messages from + * the receiver). */ void set_msg_fd_in(int fd) { msg_fd_in = fd; } -/** Setup the fd used to send our MSG_* messages. Only needed when - * we're the receiver because the generator and the sender both use - * the multiplexed I/O setup. */ +/* Setup the fd used to send our MSG_* messages. Only needed when + * we're the receiver (to send our messages to the generator). */ void set_msg_fd_out(int fd) { msg_fd_out = fd; @@ -205,8 +206,10 @@ msg_list_push(NORMAL_FLUSH); } -/** Read a message from the MSG_* fd and dispatch it. This is only - * called by the generator. */ +/* Read a message from the MSG_* fd and handle it. This is called either + * during the early stages of being a local sender (up through the sending + * of the file list) or when we're the generator (to fetch the messages + * from the receiver). */ static void read_msg_fd(void) { char buf[2048]; @@ -226,14 +229,14 @@ switch (tag) { case MSG_DONE: - if (len != 0) { + if (len != 0 || !am_generator) { rprintf(FERROR, "invalid message %d:%d\n", tag, len); exit_cleanup(RERR_STREAMIO); } redo_list_add(-1); break; case MSG_REDO: - if (len != 4) { + if (len != 4 || !am_generator) { rprintf(FERROR, "invalid message %d:%d\n", tag, len); exit_cleanup(RERR_STREAMIO); } --- main.c 13 Nov 2004 22:32:34 -0000 1.222 +++ main.c 20 Nov 2004 17:10:54 -0000 1.224 @@ -562,6 +562,13 @@ struct file_list *flist; char *local_name = NULL; char *dir = NULL; + int save_verbose = verbose; + + if (filesfrom_fd >= 0) { + /* We can't mix messages with files-from data on the socket, + * so temporarily turn off verbose messages. */ + verbose = 0; + } if (verbose > 2) { rprintf(FINFO, "server_recv(%d) starting pid=%ld\n", @@ -591,15 +598,17 @@ recv_exclude_list(f_in); if (filesfrom_fd >= 0) { - /* We're receiving the file info from the sender, so we need - * the IO routines to automatically write out the names onto - * our f_out socket as we read the list info from the sender. - * This avoids both deadlock and extra delays/buffers. */ + /* We need to send the files-from names to the sender at the + * same time that we receive the file-list from them, so we + * need the IO routines to automatically write out the names + * onto our f_out socket as we read the file-list. This + * avoids both deadlock and extra delays/buffers. */ io_set_filesfrom_fds(filesfrom_fd, f_out); filesfrom_fd = -1; } flist = recv_file_list(f_in); + verbose = save_verbose; if (!flist) { rprintf(FERROR,"server_recv: recv_file_list error\n"); exit_cleanup(RERR_FILESELECT); @@ -688,6 +697,8 @@ if (am_sender) { keep_dirlinks = 0; /* Must be disabled on the sender. */ io_start_buffering_out(); + if (!remote_filesfrom_file) + set_msg_fd_in(f_in); if (cvs_exclude) add_cvs_excludes(); if (delete_mode && !delete_excluded) @@ -699,6 +710,7 @@ start_write_batch(f_out); if (!read_batch) /* don't write to pipe */ flist = send_file_list(f_out,argc,argv); + set_msg_fd_in(-1); if (verbose > 3) rprintf(FINFO,"file list sent\n");