Change the msg pipe to use a real multiplexed IO mode
[rsync/rsync.git] / main.c
diff --git a/main.c b/main.c
index 75e9a2f..d8055cb 100644 (file)
--- a/main.c
+++ b/main.c
@@ -82,9 +82,10 @@ extern char curr_dir[MAXPATHLEN];
 extern char backup_dir_buf[MAXPATHLEN];
 extern char *basis_dir[MAX_BASIS_DIRS+1];
 extern struct file_list *first_flist;
-extern struct filter_list_struct daemon_filter_list;
+extern filter_rule_list daemon_filter_list;
 
 uid_t our_uid;
+gid_t our_gid;
 int am_generator = 0;
 int local_server = 0;
 int daemon_over_rsh = 0;
@@ -825,10 +826,8 @@ static int do_recv(int f_in, int f_out, char *local_name)
                        exit_cleanup(RERR_SYNTAX);
                if (ret)
                        rprintf(FINFO, "Created backup_dir %s\n", backup_dir_buf);
-               else if (INFO_GTE(BACKUP, 1)) {
-                       char *dir = *backup_dir_buf ? backup_dir_buf : ".";
-                       rprintf(FINFO, "backup_dir is %s\n", dir);
-               }
+               else if (INFO_GTE(BACKUP, 1))
+                       rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf);
        }
 
        io_flush(NORMAL_FLUSH);
@@ -848,7 +847,7 @@ static int do_recv(int f_in, int f_out, char *local_name)
 
                /* set place to send errors */
                set_msg_fd_out(error_pipe[1]);
-               io_start_buffering_out(error_pipe[1]);
+               io_start_multiplex_out(error_pipe[1]);
 
                recv_files(f_in, local_name);
                io_flush(FULL_FLUSH);
@@ -896,7 +895,7 @@ static int do_recv(int f_in, int f_out, char *local_name)
        io_start_buffering_out(f_out);
 
        set_msg_fd_in(error_pipe[0]);
-       io_start_buffering_in(error_pipe[0]);
+       io_start_multiplex_in(error_pipe[0]);
 
 #ifdef SUPPORT_HARD_LINKS
        if (preserve_hard_links && inc_recurse) {
@@ -960,7 +959,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
        }
 
        if (protocol_version >= 30)
-               io_start_multiplex_in();
+               io_start_multiplex_in(f_in);
        else
                io_start_buffering_in(f_in);
        recv_filter_list(f_in);
@@ -1002,7 +1001,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
 
        if (daemon_filter_list.head) {
                char **dir_p;
-               struct filter_list_struct *elp = &daemon_filter_list;
+               filter_rule_list *elp = &daemon_filter_list;
 
                for (dir_p = basis_dir; *dir_p; dir_p++) {
                        char *dir = *dir_p;
@@ -1041,12 +1040,12 @@ void start_server(int f_in, int f_out, int argc, char *argv[])
        setup_protocol(f_out, f_in);
 
        if (protocol_version >= 23)
-               io_start_multiplex_out();
+               io_start_multiplex_out(f_out);
 
        if (am_sender) {
                keep_dirlinks = 0; /* Must be disabled on the sender. */
                if (need_messages_from_generator)
-                       io_start_multiplex_in();
+                       io_start_multiplex_in(f_in);
                recv_filter_list(f_in);
                do_server_sender(f_in, f_out, argc, argv);
        } else
@@ -1093,7 +1092,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
                        sender_keeps_checksum = 1;
 
                if (protocol_version >= 30)
-                       io_start_multiplex_out();
+                       io_start_multiplex_out(f_out);
                else
                        io_start_buffering_out(f_out);
                if (!filesfrom_host)
@@ -1109,7 +1108,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
                        rprintf(FINFO,"file list sent\n");
 
                if (protocol_version >= 23)
-                       io_start_multiplex_in();
+                       io_start_multiplex_in(f_in);
 
                io_flush(NORMAL_FLUSH);
                send_files(f_in, f_out);
@@ -1130,9 +1129,9 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
 
        if (!read_batch) {
                if (protocol_version >= 23)
-                       io_start_multiplex_in();
+                       io_start_multiplex_in(f_in);
                if (need_messages_from_generator)
-                       io_start_multiplex_out();
+                       io_start_multiplex_out(f_out);
        }
 
        send_filter_list(read_batch ? -1 : f_out);
@@ -1487,6 +1486,7 @@ int main(int argc,char *argv[])
 
        starttime = time(NULL);
        our_uid = MY_UID();
+       our_gid = MY_GID();
        am_root = our_uid == 0;
 
        memset(&stats, 0, sizeof(stats));