Don't send MSG_ERROR_EXIT messages at the end of the transfer.
authorWayne Davison <wayned@samba.org>
Sat, 12 Dec 2009 16:54:36 +0000 (08:54 -0800)
committerWayne Davison <wayned@samba.org>
Sat, 12 Dec 2009 16:54:36 +0000 (08:54 -0800)
Added some debug output for MSG_ERROR_EXIT messages.

cleanup.c
io.c
main.c
options.c

index 63118e6b87b9b7da0950f448cf9b10122dba7e83..5981bac8e9243b3904c3ab5275259171bd3826dc 100644 (file)
--- 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 9b1cdbcb46467338011c2d68a32ea049ca6ba1b3..9aab9dce679dc7bca0c8a88540f8ab75ea409df8 100644 (file)
--- 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 038214fda7aba753b4be1e2b45f6b809d5057577..3f194f1b73b28e485100f04b32261f60219dad6a 100644 (file)
--- 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);
index b307adf18ba6114785f2008dea2ba1ff4f610cea..1f8f5721752f0ca20e0e24a97bda4d457cb6293b 100644 (file)
--- 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)"),