X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/64c3523a6f1f5d6c83571f5f7e921129af42d177..d6631cf3a5287c66b61691557305c486dcb74cae:/main.c diff --git a/main.c b/main.c index 1b0cd8b1..e59b301e 100644 --- a/main.c +++ b/main.c @@ -55,7 +55,7 @@ void wait_process(pid_t pid, int *status) while ((waited_pid = waitpid(pid, status, WNOHANG)) == 0) { msleep(20); - io_flush(); + io_flush(FULL_FLUSH); } if ((waited_pid == -1) && (errno == ECHILD)) { @@ -380,14 +380,16 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[]) exit_cleanup(0); } + io_start_buffering_in(f_in); + io_start_buffering_out(f_out); send_files(flist,f_out,f_in); - io_flush(); + io_flush(FULL_FLUSH); report(f_out); if (protocol_version >= 24) { /* final goodbye message */ read_int(f_in); } - io_flush(); + io_flush(FULL_FLUSH); exit_cleanup(0); } @@ -396,7 +398,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) { int pid; int status=0; - int recv_pipe[2]; int error_pipe[2]; extern int preserve_hard_links; extern int delete_after; @@ -413,20 +414,14 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) } } - if (fd_pair(recv_pipe) < 0) { - rprintf(FERROR,"pipe failed in do_recv\n"); - exit_cleanup(RERR_SOCKETIO); - } - if (fd_pair(error_pipe) < 0) { rprintf(FERROR,"error pipe failed in do_recv\n"); exit_cleanup(RERR_SOCKETIO); } - io_flush(); + io_flush(NORMAL_FLUSH); if ((pid=do_fork()) == 0) { - close(recv_pipe[0]); close(error_pipe[0]); if (f_in != f_out) close(f_out); @@ -434,41 +429,39 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) io_multiplexing_close(); /* set place to send errors */ - set_error_fd(error_pipe[1]); + set_msg_fd_out(error_pipe[1]); - recv_files(f_in,flist,local_name,recv_pipe[1]); - io_flush(); + recv_files(f_in,flist,local_name); + io_flush(FULL_FLUSH); report(f_in); - write_int(recv_pipe[1],1); - close(recv_pipe[1]); - io_flush(); + send_msg(MSG_DONE, "", 0); + io_flush(FULL_FLUSH); /* finally we go to sleep until our parent kills us * with a USR2 signal. We sleep for a short time as on * some OSes a signal won't interrupt a sleep! */ - while (msleep(20)) - ; + while (1) + msleep(20); } - close(recv_pipe[1]); close(error_pipe[1]); if (f_in != f_out) close(f_in); - io_start_buffering(f_out); + io_start_buffering_out(f_out); - io_set_error_fd(error_pipe[0]); + set_msg_fd_in(error_pipe[0]); - generate_files(f_out,flist,local_name,recv_pipe[0]); + generate_files(f_out, flist, local_name); - read_int(recv_pipe[0]); - close(recv_pipe[0]); + get_redo_num(); /* Read final -1, and any prior messages. */ + io_flush(FULL_FLUSH); if (protocol_version >= 24) { /* send a final goodbye message */ write_int(f_out, -1); } - io_flush(); + io_flush(FULL_FLUSH); - io_set_error_fd(-1); + set_msg_fd_in(-1); kill(pid, SIGUSR2); wait_process(pid, &status); return status; @@ -508,6 +501,7 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[]) } } + io_start_buffering_in(f_in); if (delete_mode && !delete_excluded) recv_exclude_list(f_in); @@ -606,6 +600,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) extern int cvs_exclude; extern int delete_mode; extern int delete_excluded; + io_start_buffering_out(f_out); if (cvs_exclude) add_cvs_excludes(); if (delete_mode && !delete_excluded) @@ -617,7 +612,10 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) if (verbose > 3) rprintf(FINFO,"file list sent\n"); + io_flush(NORMAL_FLUSH); + io_start_buffering_out(f_out); send_files(flist,f_out,f_in); + io_flush(FULL_FLUSH); if (protocol_version >= 24) { /* final goodbye message */ read_int(f_in); @@ -625,10 +623,11 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) if (pid != -1) { if (verbose > 3) rprintf(FINFO,"client_run waiting on %d\n", (int) pid); - io_flush(); + io_flush(FULL_FLUSH); wait_process(pid, &status); } report(-1); + io_flush(FULL_FLUSH); exit_cleanup(status); } @@ -660,7 +659,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) if (pid != -1) { if (verbose > 3) rprintf(FINFO,"client_run2 waiting on %d\n", (int) pid); - io_flush(); + io_flush(FULL_FLUSH); wait_process(pid, &status); }