Commit f1e3656e authored by Wayne Davison's avatar Wayne Davison

- Call io_flush() with its new FULL_FLUSH/NORMAL_FLUSH arg.

- Got rid of the recv_pipe between the receiver and the generator.
- Use new send_msg(MSG_DONE,...) call to signal the generator
  when the receiver is done.
- Use the new get_redo_num() call in the generator to read the
  final -1 from the receiver.
parent a644fc3c
...@@ -55,7 +55,7 @@ void wait_process(pid_t pid, int *status) ...@@ -55,7 +55,7 @@ void wait_process(pid_t pid, int *status)
while ((waited_pid = waitpid(pid, status, WNOHANG)) == 0) { while ((waited_pid = waitpid(pid, status, WNOHANG)) == 0) {
msleep(20); msleep(20);
io_flush(); io_flush(FULL_FLUSH);
} }
if ((waited_pid == -1) && (errno == ECHILD)) { if ((waited_pid == -1) && (errno == ECHILD)) {
...@@ -383,13 +383,13 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[]) ...@@ -383,13 +383,13 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
io_start_buffering_in(f_in); io_start_buffering_in(f_in);
io_start_buffering_out(f_out); io_start_buffering_out(f_out);
send_files(flist,f_out,f_in); send_files(flist,f_out,f_in);
io_flush(); io_flush(FULL_FLUSH);
report(f_out); report(f_out);
if (protocol_version >= 24) { if (protocol_version >= 24) {
/* final goodbye message */ /* final goodbye message */
read_int(f_in); read_int(f_in);
} }
io_flush(); io_flush(FULL_FLUSH);
exit_cleanup(0); exit_cleanup(0);
} }
...@@ -398,7 +398,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) ...@@ -398,7 +398,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{ {
int pid; int pid;
int status=0; int status=0;
int recv_pipe[2];
int error_pipe[2]; int error_pipe[2];
extern int preserve_hard_links; extern int preserve_hard_links;
extern int delete_after; extern int delete_after;
...@@ -415,20 +414,14 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) ...@@ -415,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) { if (fd_pair(error_pipe) < 0) {
rprintf(FERROR,"error pipe failed in do_recv\n"); rprintf(FERROR,"error pipe failed in do_recv\n");
exit_cleanup(RERR_SOCKETIO); exit_cleanup(RERR_SOCKETIO);
} }
io_flush(); io_flush(NORMAL_FLUSH);
if ((pid=do_fork()) == 0) { if ((pid=do_fork()) == 0) {
close(recv_pipe[0]);
close(error_pipe[0]); close(error_pipe[0]);
if (f_in != f_out) close(f_out); if (f_in != f_out) close(f_out);
...@@ -436,41 +429,39 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) ...@@ -436,41 +429,39 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
io_multiplexing_close(); io_multiplexing_close();
/* set place to send errors */ /* 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]); recv_files(f_in,flist,local_name);
io_flush(); io_flush(FULL_FLUSH);
report(f_in); report(f_in);
write_int(recv_pipe[1],1); send_msg(MSG_DONE, "", 0);
close(recv_pipe[1]); io_flush(FULL_FLUSH);
io_flush();
/* finally we go to sleep until our parent kills us /* finally we go to sleep until our parent kills us
* with a USR2 signal. We sleep for a short time as on * with a USR2 signal. We sleep for a short time as on
* some OSes a signal won't interrupt a sleep! */ * some OSes a signal won't interrupt a sleep! */
while (msleep(20)) while (1)
; msleep(20);
} }
close(recv_pipe[1]);
close(error_pipe[1]); close(error_pipe[1]);
if (f_in != f_out) close(f_in); if (f_in != f_out) close(f_in);
io_start_buffering_out(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]); get_redo_num(); /* Read final -1, and any prior messages. */
close(recv_pipe[0]); io_flush(FULL_FLUSH);
if (protocol_version >= 24) { if (protocol_version >= 24) {
/* send a final goodbye message */ /* send a final goodbye message */
write_int(f_out, -1); write_int(f_out, -1);
} }
io_flush(); io_flush(FULL_FLUSH);
io_set_error_fd(-1); set_msg_fd_in(-1);
kill(pid, SIGUSR2); kill(pid, SIGUSR2);
wait_process(pid, &status); wait_process(pid, &status);
return status; return status;
...@@ -621,10 +612,10 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) ...@@ -621,10 +612,10 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"file list sent\n"); rprintf(FINFO,"file list sent\n");
io_flush(); io_flush(NORMAL_FLUSH);
io_start_buffering_out(f_out); io_start_buffering_out(f_out);
send_files(flist,f_out,f_in); send_files(flist,f_out,f_in);
io_flush(); io_flush(FULL_FLUSH);
if (protocol_version >= 24) { if (protocol_version >= 24) {
/* final goodbye message */ /* final goodbye message */
read_int(f_in); read_int(f_in);
...@@ -632,11 +623,11 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) ...@@ -632,11 +623,11 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
if (pid != -1) { if (pid != -1) {
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"client_run waiting on %d\n", (int) pid); rprintf(FINFO,"client_run waiting on %d\n", (int) pid);
io_flush(); io_flush(FULL_FLUSH);
wait_process(pid, &status); wait_process(pid, &status);
} }
report(-1); report(-1);
io_flush(); io_flush(FULL_FLUSH);
exit_cleanup(status); exit_cleanup(status);
} }
...@@ -668,7 +659,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) ...@@ -668,7 +659,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
if (pid != -1) { if (pid != -1) {
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"client_run2 waiting on %d\n", (int) pid); rprintf(FINFO,"client_run2 waiting on %d\n", (int) pid);
io_flush(); io_flush(FULL_FLUSH);
wait_process(pid, &status); wait_process(pid, &status);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment