Fixed a bug where deferred MSG_INFO/MSG_ERROR/MSG_LOG messages were
authorWayne Davison <wayned@samba.org>
Wed, 3 May 2006 05:19:01 +0000 (05:19 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 3 May 2006 05:19:01 +0000 (05:19 +0000)
not being forwarded from the generator to the sender using rwrite()
(and MSG_LOG messages didn't need to be deferred at all).

io.c

diff --git a/io.c b/io.c
index 255b442..e235d3e 100644 (file)
--- a/io.c
+++ b/io.c
@@ -294,6 +294,7 @@ static void read_msg_fd(void)
                        exit_cleanup(RERR_STREAMIO);
                }
                close_multiplexing_out();
+               defer_forwarding_messages = 0;
                /* FALL THROUGH */
        case MSG_INFO:
        case MSG_ERROR:
@@ -303,7 +304,8 @@ static void read_msg_fd(void)
                        if (n >= sizeof buf)
                                n = sizeof buf - 1;
                        read_loop(fd, buf, n);
-                       if (am_generator && am_server && defer_forwarding_messages)
+                       if (am_generator && am_server
+                        && defer_forwarding_messages && tag != MSG_LOG)
                                msg_list_add(&msg2sndr, tag, buf, n);
                        else
                                rwrite((enum logcode)tag, buf, n);
@@ -1134,11 +1136,20 @@ static void msg2sndr_flush(void)
 
        while (msg2sndr.head && io_multiplexing_out) {
                struct msg_list_item *m = msg2sndr.head;
+               int tag = (IVAL(m->buf, 0) >> 24) - MPLEX_BASE;
                if (!(msg2sndr.head = m->next))
                        msg2sndr.tail = NULL;
-               stats.total_written += m->len;
                defer_forwarding_messages = 1;
-               writefd_unbuffered(sock_f_out, m->buf, m->len);
+               switch (tag) {
+               case MSG_INFO:
+               case MSG_ERROR:
+                       rwrite((enum logcode)tag, m->buf + 4, m->len - 4);
+                       break;
+               default:
+                       stats.total_written += m->len;
+                       writefd_unbuffered(sock_f_out, m->buf, m->len);
+                       break;
+               }
                defer_forwarding_messages = 0;
                free(m);
        }