Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
report exit code when failing a test
[rsync/rsync.git]
/
main.c
diff --git
a/main.c
b/main.c
index
404d49b
..
a546778
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-278,22
+278,45
@@
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 pid;
int status=0;
int recv_pipe[2];
+ int error_pipe[2];
extern int preserve_hard_links;
extern int preserve_hard_links;
+ extern int delete_after;
+ extern int recurse;
+ extern int delete_mode;
if (preserve_hard_links)
init_hard_links(flist);
if (preserve_hard_links)
init_hard_links(flist);
+ if (!delete_after) {
+ /* I moved this here from recv_files() to prevent a race condition */
+ if (recurse && delete_mode && !local_name && flist->count>0) {
+ delete_files(flist);
+ }
+ }
+
if (pipe(recv_pipe) < 0) {
rprintf(FERROR,"pipe failed in do_recv\n");
exit_cleanup(RERR_SOCKETIO);
}
if (pipe(recv_pipe) < 0) {
rprintf(FERROR,"pipe failed in do_recv\n");
exit_cleanup(RERR_SOCKETIO);
}
+
+ if (pipe(error_pipe) < 0) {
+ rprintf(FERROR,"error pipe failed in do_recv\n");
+ exit_cleanup(RERR_SOCKETIO);
+ }
io_flush();
if ((pid=do_fork()) == 0) {
close(recv_pipe[0]);
io_flush();
if ((pid=do_fork()) == 0) {
close(recv_pipe[0]);
+ close(error_pipe[0]);
if (f_in != f_out) close(f_out);
if (f_in != f_out) close(f_out);
+ /* we can't let two processes write to the socket at one time */
+ io_multiplexing_close();
+
+ /* set place to send errors */
+ set_error_fd(error_pipe[1]);
+
recv_files(f_in,flist,local_name,recv_pipe[1]);
report(f_in);
recv_files(f_in,flist,local_name,recv_pipe[1]);
report(f_in);
@@
-302,11
+325,14
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
}
close(recv_pipe[1]);
}
close(recv_pipe[1]);
+ close(error_pipe[1]);
io_close_input(f_in);
if (f_in != f_out) close(f_in);
io_start_buffering(f_out);
io_close_input(f_in);
if (f_in != f_out) close(f_in);
io_start_buffering(f_out);
+ io_set_error_fd(error_pipe[0]);
+
generate_files(f_out,flist,local_name,recv_pipe[0]);
io_flush();
generate_files(f_out,flist,local_name,recv_pipe[0]);
io_flush();