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 63118e6..5981bac 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;
 
 extern char *partial_dir;
 extern char *logfile_name;
 
+BOOL shutting_down = False;
+
 #ifdef HAVE_SIGACTION
 static struct sigaction sigact;
 #endif
 #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,
 
                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 */
                }
 
                /* FALLTHROUGH */
@@ -205,18 +207,23 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
 
                if (DEBUG_GTE(EXIT, 1)) {
                        rprintf(FINFO,
 
                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",
                                "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
                }
 
                /* 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);
                                send_msg_int(MSG_ERROR_EXIT, exit_code);
+                       }
                        noop_io_until_death();
                }
 
                        noop_io_until_death();
                }
 
diff --git a/io.c b/io.c
index 9b1cdbc..9aab9dc 100644 (file)
--- a/io.c
+++ b/io.c
@@ -1489,8 +1489,14 @@ static void read_a_msg(void)
                }
                break;
        case MSG_ERROR_EXIT:
                }
                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 (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);
                        }
                                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) {
                        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);
                                        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);
                                        send_msg(MSG_ERROR_EXIT, "", 0, 0);
+                               }
                        }
                } else
                        goto invalid_msg;
                        }
                } else
                        goto invalid_msg;
diff --git a/main.c b/main.c
index 038214f..3f194f1 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 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;
 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];
 
        uchar fnamecmp_type;
        char xname[MAXPATHLEN];
 
+       shutting_down = True;
+
        if (protocol_version < 29)
                i = read_int(f_in);
        else {
        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);
 
        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);
        if (protocol_version >= 24) {
                /* send a final goodbye message */
                write_ndx(f_out, NDX_DONE);
index b307adf..1f8f572 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(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)"),
        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)"),