diff options
author | Wayne Davison <wayned@samba.org> | 2009-11-07 00:39:50 -0800 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2009-11-07 01:22:11 -0800 |
commit | f9185203ee03152001530db5624a2b8c93e1ea94 (patch) | |
tree | 8b1fb3dff27b0d87412a6739aba1f6de027a8e73 /cleanup.c | |
parent | 84c11e85a4c4a12ecacba24afe9617222e4361e6 (diff) | |
download | rsync-f9185203ee03152001530db5624a2b8c93e1ea94.tar.gz |
Added notifications about error-exit values:
- The receiver notifies the generator if it is exiting with an error,
and then, if it is a server, waits around for the generator to die.
This ensures that the client side has time to read the error.
- The generator or sender will notifiy the other side of the transfer of
an error-exit value if protocol 31 is in effect. This will get rid of
some "connection unexpectedly closed" errors that are really expected
events due to a fatal exit on the other side.
Diffstat (limited to 'cleanup.c')
-rw-r--r-- | cleanup.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -24,9 +24,12 @@ extern int am_server; extern int am_daemon; +extern int am_sender; +extern int am_generator; extern int io_error; extern int keep_partial; extern int got_xfer_error; +extern int protocol_version; extern int output_needs_newline; extern char *partial_dir; extern char *logfile_name; @@ -130,6 +133,17 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) /* FALLTHROUGH */ #include "case_N.h" + if (exit_code && exit_code != RERR_RCVR_ERROR + && exit_code != RERR_STREAMIO && exit_code != RERR_SIGNAL1 + && (protocol_version >= 31 || (!am_sender && !am_generator))) { + send_msg_int(MSG_ERROR_EXIT, exit_code); + if (am_server && !am_sender && !am_generator) + noop_io_until_death(); + } + + /* FALLTHROUGH */ +#include "case_N.h" + if (cleanup_child_pid != -1) { int status; int pid = wait_process(cleanup_child_pid, &status, WNOHANG); @@ -160,7 +174,8 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) /* FALLTHROUGH */ #include "case_N.h" - io_flush(FULL_FLUSH); + if (!code || am_server || (!am_sender && !am_generator)) + io_flush(FULL_FLUSH); /* FALLTHROUGH */ #include "case_N.h" @@ -184,7 +199,8 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) code = exit_code = RERR_PARTIAL; } - if (code || am_daemon || (logfile_name && (am_server || !INFO_GTE(STATS, 1)))) + if ((code && code != RERR_RCVR_ERROR) + || am_daemon || (logfile_name && (am_server || !INFO_GTE(STATS, 1)))) log_exit(code, file, line); /* FALLTHROUGH */ |