Avoid I/O via signal-handler thread.
[rsync.git] / cleanup.c
index 9de6eab8315fb7658f308298edc043cb8e127dfc..971154ceca4058572ab899aa5178e418ff127323 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -34,6 +34,7 @@ extern char *partial_dir;
 extern char *logfile_name;
 
 BOOL shutting_down = False;
+BOOL flush_ok_after_signal = False;
 
 #ifdef HAVE_SIGACTION
 static struct sigaction sigact;
@@ -182,7 +183,12 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
 #include "case_N.h"
                switch_step++;
 
-               if (!code || am_server || am_receiver)
+               if (flush_ok_after_signal) {
+                       flush_ok_after_signal = False;
+                       if (code == RERR_SIGNAL)
+                               io_flush(FULL_FLUSH);
+               }
+               if (!code)
                        io_flush(FULL_FLUSH);
 
                /* FALLTHROUGH */