From: Wayne Davison Date: Sat, 12 Dec 2009 16:54:36 +0000 (-0800) Subject: Don't send MSG_ERROR_EXIT messages at the end of the transfer. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/0c2e8f93643fd94a8d388e4373c30331d0af75b4 Don't send MSG_ERROR_EXIT messages at the end of the transfer. Added some debug output for MSG_ERROR_EXIT messages. --- diff --git a/cleanup.c b/cleanup.c index 63118e6b..5981bac8 100644 --- a/cleanup.c +++ b/cleanup.c @@ -34,6 +34,8 @@ extern int output_needs_newline; extern char *partial_dir; extern char *logfile_name; +BOOL shutting_down = False; + #ifdef HAVE_SIGACTION static struct sigaction sigact; #endif @@ -132,8 +134,8 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) if (DEBUG_GTE(EXIT, 2)) { rprintf(FINFO, - "_exit_cleanup(code=%d, file=%s, line=%d): entered\n", - code, file, line); + "[%s] _exit_cleanup(code=%d, file=%s, line=%d): entered\n", + who_am_i(), code, file, line); } /* FALLTHROUGH */ @@ -205,18 +207,23 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) if (DEBUG_GTE(EXIT, 1)) { rprintf(FINFO, - "_exit_cleanup(code=%d, file=%s, line=%d): " + "[%s] _exit_cleanup(code=%d, file=%s, line=%d): " "about to call exit(%d)\n", - unmodified_code, file, line, code); + who_am_i(), unmodified_code, file, line, code); } /* FALLTHROUGH */ #include "case_N.h" if (exit_code && exit_code != RERR_SOCKETIO && exit_code != RERR_STREAMIO && exit_code != RERR_SIGNAL1 - && (protocol_version >= 31 || (!am_sender && !am_generator))) { - if (line > 0) + && !shutting_down && (protocol_version >= 31 || (!am_sender && !am_generator))) { + if (line > 0) { + if (DEBUG_GTE(EXIT, 3)) { + rprintf(FINFO, "[%s] sending MSG_ERROR_EXIT with exit_code %d\n", + who_am_i(), exit_code); + } send_msg_int(MSG_ERROR_EXIT, exit_code); + } noop_io_until_death(); } diff --git a/io.c b/io.c index 9b1cdbcb..9aab9dce 100644 --- a/io.c +++ b/io.c @@ -1489,8 +1489,14 @@ static void read_a_msg(void) } break; case MSG_ERROR_EXIT: + if (DEBUG_GTE(EXIT, 3)) + rprintf(FINFO, "[%s] got MSG_ERROR_EXIT with %d bytes\n", who_am_i(), msg_bytes); if (msg_bytes == 0) { if (!am_sender && !am_generator) { + if (DEBUG_GTE(EXIT, 3)) { + rprintf(FINFO, "[%s] sending MSG_ERROR_EXIT (len 0)\n", + who_am_i()); + } send_msg(MSG_ERROR_EXIT, "", 0, 0); io_flush(FULL_FLUSH); } @@ -1499,10 +1505,19 @@ static void read_a_msg(void) data = perform_io(4, PIO_INPUT_AND_CONSUME); val = IVAL(data, 0); if (protocol_version >= 31) { - if (am_generator) + if (am_generator) { + if (DEBUG_GTE(EXIT, 3)) { + rprintf(FINFO, "[%s] sending MSG_ERROR_EXIT with exit_code %d\n", + who_am_i(), val); + } send_msg_int(MSG_ERROR_EXIT, val); - else + } else { + if (DEBUG_GTE(EXIT, 3)) { + rprintf(FINFO, "[%s] sending MSG_ERROR_EXIT (len 0)\n", + who_am_i()); + } send_msg(MSG_ERROR_EXIT, "", 0, 0); + } } } else goto invalid_msg; diff --git a/main.c b/main.c index 038214fd..3f194f1b 100644 --- a/main.c +++ b/main.c @@ -73,6 +73,7 @@ extern int send_msgs_to_gen; extern pid_t cleanup_child_pid; extern size_t bwlimit_writemax; extern unsigned int module_dirlen; +extern BOOL shutting_down; extern struct stats stats; extern char *stdout_format; extern char *logfile_format; @@ -726,6 +727,8 @@ static void read_final_goodbye(int f_in, int f_out) uchar fnamecmp_type; char xname[MAXPATHLEN]; + shutting_down = True; + if (protocol_version < 29) i = read_int(f_in); else { @@ -921,6 +924,7 @@ static int do_recv(int f_in, int f_out, char *local_name) handle_stats(-1); io_flush(FULL_FLUSH); + shutting_down = True; if (protocol_version >= 24) { /* send a final goodbye message */ write_ndx(f_out, NDX_DONE); diff --git a/options.c b/options.c index b307adf1..1f8f5721 100644 --- a/options.c +++ b/options.c @@ -271,7 +271,7 @@ static struct output_struct debug_words[COUNT_DEBUG+1] = { DEBUG_WORD(DEL, W_REC, "Debug delete actions (levels 1-3)"), DEBUG_WORD(DELTASUM, W_SND|W_REC, "Debug delta-transfer checksumming (levels 1-4)"), DEBUG_WORD(DUP, W_REC, "Debug weeding of duplicate names"), - DEBUG_WORD(EXIT, W_CLI|W_SRV, "Debug exit events (levels 1-2)"), + DEBUG_WORD(EXIT, W_CLI|W_SRV, "Debug exit events (levels 1-3)"), DEBUG_WORD(FILTER, W_SND|W_REC, "Debug filter actions (levels 1-2)"), DEBUG_WORD(FLIST, W_SND|W_REC, "Debug file-list operations (levels 1-4)"), DEBUG_WORD(FUZZY, W_REC, "Debug fuzzy scoring (levels 1-2)"),