Added an am_receiver variable.
authorWayne Davison <wayned@samba.org>
Sat, 19 Dec 2009 18:14:49 +0000 (10:14 -0800)
committerWayne Davison <wayned@samba.org>
Sat, 19 Dec 2009 20:04:25 +0000 (12:04 -0800)
cleanup.c
main.c
options.c
rsync.c

index 1bd1dbb4ef21fd1d9ce18428ab8d41fcddd219f9..9a0bdd7f22a11321a1e658648b16b3d8899c30f4 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -24,6 +24,7 @@
 
 extern int am_server;
 extern int am_daemon;
+extern int am_receiver;
 extern int io_error;
 extern int keep_partial;
 extern int got_xfer_error;
@@ -160,7 +161,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_receiver)
+                       io_flush(FULL_FLUSH);
 
                /* FALLTHROUGH */
 #include "case_N.h"
diff --git a/main.c b/main.c
index 0774f1fa0fcd6a27c9c9149406f326f7de7bbd44..5dec1c7852b580fa961eb310c6d1278c68794c29 100644 (file)
--- a/main.c
+++ b/main.c
@@ -81,6 +81,8 @@ extern struct file_list *first_flist;
 extern struct filter_list_struct daemon_filter_list;
 
 uid_t our_uid;
+int am_receiver = 0;  /* Only set to 1 after the receiver/generator fork. */
+int am_generator = 0; /* Only set to 1 after the receiver/generator fork. */
 int local_server = 0;
 int daemon_over_rsh = 0;
 mode_t orig_umask = 0;
@@ -760,6 +762,8 @@ static int do_recv(int f_in, int f_out, char *local_name)
        }
 
        if (pid == 0) {
+               am_receiver = 1;
+
                close(error_pipe[0]);
                if (f_in != f_out)
                        close(f_out);
index 7b9e5a8d36b3125be0893058a7f64b41f82d2d0a..5f0e8fc5d580d4632902a6dca7e92adfa1f192d8 100644 (file)
--- a/options.c
+++ b/options.c
@@ -78,7 +78,6 @@ int def_compress_level = Z_DEFAULT_COMPRESSION;
 int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */
 int am_server = 0;
 int am_sender = 0;
-int am_generator = 0;
 int am_starting_up = 1;
 int relative_paths = -1;
 int implied_dirs = 1;
diff --git a/rsync.c b/rsync.c
index 8fad34836324ea2555e5180fc09f993fbda8aef5..de61cb3a610a66f8050eb723a9c75fb404fc86be 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -37,6 +37,7 @@ extern int preserve_times;
 extern int am_root;
 extern int am_server;
 extern int am_sender;
+extern int am_receiver;
 extern int am_generator;
 extern int am_starting_up;
 extern int allow_8bit_chars;
@@ -653,5 +654,8 @@ const char *who_am_i(void)
 {
        if (am_starting_up)
                return am_server ? "server" : "client";
-       return am_sender ? "sender" : am_generator ? "generator" : "receiver";
+       return am_sender ? "sender"
+            : am_generator ? "generator"
+            : am_receiver ? "receiver"
+            : "Receiver"; /* pre-forked receiver */
 }