Improved the handling of --msgs2stderr a little more.
authorWayne Davison <wayned@samba.org>
Mon, 21 Jul 2008 05:20:17 +0000 (22:20 -0700)
committerWayne Davison <wayned@samba.org>
Mon, 21 Jul 2008 05:27:23 +0000 (22:27 -0700)
cleanup.c
log.c

index 9146782..22e2e35 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -105,7 +105,7 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
                code = exit_code;
 
        /* If this is the exit at the end of the run, the server side
-        * should not attempt to output a message (see log.c). */
+        * should not attempt to output a message (see log_exit()). */
        if (am_server && code == 0)
                am_server = 2;
 
diff --git a/log.c b/log.c
index 5d59419..58c6bb1 100644 (file)
--- a/log.c
+++ b/log.c
@@ -258,10 +258,8 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
        if (len < 0)
                exit_cleanup(RERR_MESSAGEIO);
 
-       if (msgs2stderr && code != FLOG) {
-               f = stderr;
+       if (msgs2stderr > 0 && code != FLOG)
                goto output_msg;
-       }
 
        if (am_server && msg_fd_out >= 0) {
                assert(!is_utf8);
@@ -312,8 +310,10 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
                        /* TODO: can we send the error to the user somehow? */
                        return;
                }
+               msgs2stderr = -1;
        }
 
+output_msg:
        switch (code) {
        case FERROR_XFER:
                got_xfer_error = 1;
@@ -323,13 +323,13 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
                f = stderr;
                break;
        case FINFO:
-               f = am_server ? stderr : stdout;
+       case FCLIENT:
+               f = msgs2stderr ? stderr : stdout;
                break;
        default:
                exit_cleanup(RERR_MESSAGEIO);
        }
 
-output_msg:
        if (output_needs_newline) {
                fputc('\n', f);
                output_needs_newline = 0;