Fixed failing hunks.
[rsync/rsync-patches.git] / threaded-receiver.diff
index d908d9a..8129c4d 100644 (file)
@@ -18,6 +18,12 @@ NOTE: we still need to duplicate the partial_fname static in util.c!
 If you try this out, please send some email to wayned@samba.org or the rsync
 mailing list with your results, build changes, bug reports, etc.  Thanks!
 
+To use this patch, run these commands for a successful build:
+
+    patch -p1 <patches/threaded-receiver.diff
+    ./configure
+    make
+
 --- old/Makefile.in
 +++ new/Makefile.in
 @@ -7,7 +7,7 @@ exec_prefix=@exec_prefix@
@@ -81,7 +87,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  extern int protocol_version;
  extern int fuzzy_basis;
  extern int always_checksum;
-@@ -95,6 +94,11 @@ extern struct filter_list_struct server_
+@@ -98,6 +97,11 @@ int non_perishable_cnt = 0;
  
  static int deletion_count = 0; /* used to implement --max-delete */
  
@@ -90,10 +96,10 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 +static int GEN_make_backups;
 +static int GEN_csum_length;
 +
- /* For calling delete_file() */
- #define DEL_FORCE_RECURSE     (1<<1) /* recurse even w/o --force */
- #define DEL_TERSE             (1<<3)
-@@ -445,8 +449,8 @@ static void sum_sizes_sqroot(struct sum_
+ /* For calling delete_item() and delete_dir_contents(). */
+ #define DEL_RECURSE           (1<<1) /* recurse */
+ #define DEL_DIR_IS_EMPTY      (1<<2) /* internal delete_FUNCTIONS use only */
+@@ -508,8 +512,8 @@ static void sum_sizes_sqroot(struct sum_
        }
  
        if (protocol_version < 27) {
@@ -104,7 +110,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                s2length = SUM_LENGTH;
        } else {
                int32 c;
-@@ -456,7 +460,7 @@ static void sum_sizes_sqroot(struct sum_
+@@ -519,7 +523,7 @@ static void sum_sizes_sqroot(struct sum_
                for (c = blength; (c >>= 1) && b; b--) {}
                /* add a bit, subtract rollsum, round up. */
                s2length = (b + 1 - 32 + 7) / 8; /* --optimize in compiler-- */
@@ -113,7 +119,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                s2length = MIN(s2length, SUM_LENGTH);
        }
  
-@@ -490,7 +494,7 @@ static void generate_and_send_sums(int f
+@@ -553,7 +557,7 @@ static void generate_and_send_sums(int f
        sum_sizes_sqroot(&sum, len);
        write_sum_head(f_out, &sum);
  
@@ -122,7 +128,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                return;
  
        if (len > 0)
-@@ -509,7 +513,7 @@ static void generate_and_send_sums(int f
+@@ -572,7 +576,7 @@ static void generate_and_send_sums(int f
  
                if (f_copy >= 0) {
                        full_write(f_copy, map, n1);
@@ -131,7 +137,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                                continue;
                }
  
-@@ -1205,7 +1209,7 @@ static void recv_generator(char *fname, 
+@@ -1348,7 +1352,7 @@ static void recv_generator(char *fname, 
                return;
        }
  
@@ -140,7 +146,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                return;
  
        if (fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH)
-@@ -1268,7 +1272,7 @@ static void recv_generator(char *fname, 
+@@ -1411,7 +1415,7 @@ static void recv_generator(char *fname, 
                goto notify_others;
        }
  
@@ -149,7 +155,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                if (!(backupptr = get_backup_name(fname))) {
                        close(fd);
                        return;
-@@ -1359,9 +1363,12 @@ void generate_files(int f_out, struct fi
+@@ -1502,9 +1506,12 @@ void generate_files(int f_out, struct fi
        int save_ignore_existing = ignore_existing;
        int save_ignore_non_existing = ignore_non_existing;
        int save_do_progress = do_progress;
@@ -163,7 +169,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
        if (protocol_version >= 29) {
                itemizing = 1;
                maybe_ATTRS_REPORT = stdout_format_has_i ? 0 : ATTRS_REPORT;
-@@ -1389,7 +1396,7 @@ void generate_files(int f_out, struct fi
+@@ -1532,7 +1539,7 @@ void generate_files(int f_out, struct fi
                do_delete_pass(flist);
        do_progress = 0;
  
@@ -172,7 +178,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                whole_file = 0;
        if (verbose >= 2) {
                rprintf(FINFO, "delta-transmission %s\n",
-@@ -1398,12 +1405,6 @@ void generate_files(int f_out, struct fi
+@@ -1541,12 +1548,6 @@ void generate_files(int f_out, struct fi
                        : "enabled");
        }
  
@@ -185,7 +191,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
        for (i = 0; i < flist->count; i++) {
                struct file_struct *file = flist->files[i];
  
-@@ -1447,23 +1448,34 @@ void generate_files(int f_out, struct fi
+@@ -1590,23 +1591,34 @@ void generate_files(int f_out, struct fi
                delete_in_dir(NULL, NULL, NULL, NULL);
  
        phase++;
@@ -226,7 +232,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                if (local_name)
                        strlcpy(fbuf, local_name, sizeof fbuf);
                else
-@@ -1475,27 +1487,43 @@ void generate_files(int f_out, struct fi
+@@ -1618,27 +1630,43 @@ void generate_files(int f_out, struct fi
        phase++;
        ignore_non_existing = save_ignore_non_existing;
        ignore_existing = save_ignore_existing;
@@ -414,8 +420,8 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 -}
 -
  /* Add a message to the pending MSG_* list. */
--static void msg_list_add(struct msg_list *lst, int code, char *buf, int len)
-+static void msg_list_add(int code, char *buf, int len)
+-static void msg_list_add(struct msg_list *lst, int code, const char *buf, int len)
++static void msg_list_add(int code, const char *buf, int len)
  {
        struct msg_list_item *m;
 -      int sz = len + 4 + sizeof m[0] - 1;
@@ -578,7 +584,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 +      no_flush--;
  }
  
- int send_msg(enum msgcode code, char *buf, int len)
+ int send_msg(enum msgcode code, const char *buf, int len)
  {
 -      if (msg_fd_out < 0) {
 +      if (!am_receiver()) {
@@ -662,7 +668,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                if ((size_t)write(batch_fd, buffer, total) != total)
                        exit_cleanup(RERR_FILEIO);
        }
-@@ -1115,7 +1067,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1115,7 +1067,6 @@ static void writefd_unbuffered(int fd, c
                         * to grab any messages they sent before they died. */
                        while (fd == sock_f_out && io_multiplexing_in) {
                                set_io_timeout(30);
@@ -670,7 +676,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                                readfd_unbuffered(sock_f_in, io_filesfrom_buf,
                                                  sizeof io_filesfrom_buf);
                        }
-@@ -1126,7 +1077,7 @@ static void writefd_unbuffered(int fd,ch
+@@ -1126,7 +1077,7 @@ static void writefd_unbuffered(int fd, c
                defer_forwarding_messages = 1;
  
                if (fd == sock_f_out) {
@@ -679,7 +685,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                                last_io_out = time(NULL);
                        sleep_for_bwlimit(cnt);
                }
-@@ -1136,23 +1087,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1136,23 +1087,6 @@ static void writefd_unbuffered(int fd, c
        no_flush--;
  }
  
@@ -725,7 +731,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                return;
 @@ -1199,11 +1134,6 @@ void io_flush(int flush_it_all)
  
- static void writefd(int fd,char *buf,size_t len)
+ static void writefd(int fd, const char *buf, size_t len)
  {
 -      if (fd == msg_fd_out) {
 -              rprintf(FERROR, "Internal error: wrong write used in receiver.\n");
@@ -763,7 +769,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
        { RERR_SIGNAL     , "received SIGINT, SIGTERM, or SIGHUP" },
        { RERR_WAITCHILD  , "waitpid() failed" },
        { RERR_MALLOC     , "error allocating core memory buffers" },
-@@ -241,8 +239,8 @@ void rwrite(enum logcode code, char *buf
+@@ -241,8 +239,8 @@ void rwrite(enum logcode code, const cha
        if (len < 0)
                exit_cleanup(RERR_MESSAGEIO);
  
@@ -814,7 +820,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                return;
  
        if (am_daemon) {
-@@ -683,12 +693,30 @@ static void do_server_sender(int f_in, i
+@@ -684,12 +694,30 @@ static void do_server_sender(int f_in, i
        exit_cleanup(0);
  }
  
@@ -848,12 +854,19 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  
        /* The receiving side mustn't obey this, or an existing symlink that
         * points to an identical file won't be replaced by the referent. */
-@@ -697,70 +725,16 @@ static int do_recv(int f_in,int f_out,st
+@@ -698,70 +726,16 @@ static int do_recv(int f_in,int f_out,st
        if (preserve_hard_links)
                init_hard_links();
  
 -      if (fd_pair(error_pipe) < 0) {
 -              rsyserr(FERROR, errno, "pipe failed in do_recv");
+-              exit_cleanup(RERR_IPC);
+-      }
+-
+-      io_flush(NORMAL_FLUSH);
+-
+-      if ((pid = do_fork()) == -1) {
+-              rsyserr(FERROR, errno, "fork failed in do_recv");
 +      args.f_in = f_in;
 +      args.flist = flist;
 +      args.local_name = local_name;
@@ -862,13 +875,6 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                exit_cleanup(RERR_IPC);
        }
  
--      io_flush(NORMAL_FLUSH);
--
--      if ((pid = do_fork()) == -1) {
--              rsyserr(FERROR, errno, "fork failed in do_recv");
--              exit_cleanup(RERR_IPC);
--      }
--
 -      if (pid == 0) {
 -              close(error_pipe[0]);
 -              if (f_in != f_out)
@@ -924,7 +930,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
        generate_files(f_out, flist, local_name);
  
        handle_stats(-1);
-@@ -771,10 +745,13 @@ static int do_recv(int f_in,int f_out,st
+@@ -772,10 +746,13 @@ static int do_recv(int f_in,int f_out,st
        }
        io_flush(FULL_FLUSH);
  
@@ -942,7 +948,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  }
  
  
-@@ -1176,22 +1153,6 @@ static int start_client(int argc, char *
+@@ -1177,22 +1154,6 @@ static int start_client(int argc, char *
        return ret;
  }
  
@@ -965,7 +971,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  RETSIGTYPE remember_children(UNUSED(int val))
  {
  #ifdef WNOHANG
-@@ -1283,8 +1244,6 @@ int main(int argc,char *argv[])
+@@ -1284,8 +1245,6 @@ int main(int argc,char *argv[])
  # endif
        sigact.sa_flags = SA_NOCLDSTOP;
  #endif
@@ -1006,7 +1012,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 @@ -325,7 +325,7 @@ void match_sums(int f, struct sum_struct
                }
                if (last_match < s->flength) {
-                       int32 len = s->flength - last_match;
+                       int32 len = (int32)(s->flength - last_match);
 -                      if (buf && do_progress)
 +                      if (buf && recv_progress)
                                show_progress(last_match, buf->file_size);
@@ -1040,7 +1046,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
                do_xfers = 0;
 --- old/pipe.c
 +++ new/pipe.c
-@@ -59,7 +59,7 @@ pid_t piped_child(char **command, int *f
+@@ -58,7 +58,7 @@ pid_t piped_child(char **command, int *f
                exit_cleanup(RERR_IPC);
        }
  
@@ -1049,7 +1055,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
        if (pid == -1) {
                rsyserr(FERROR, errno, "fork");
                exit_cleanup(RERR_IPC);
-@@ -123,7 +123,7 @@ pid_t local_child(int argc, char **argv,
+@@ -122,7 +122,7 @@ pid_t local_child(int argc, char **argv,
                exit_cleanup(RERR_IPC);
        }
  
@@ -1081,7 +1087,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 @@ -165,7 +165,7 @@ static int receive_data(int f_in, char *
                }
                if (offset < sum.flength) {
-                       int32 len = sum.flength - offset;
+                       int32 len = (int32)(sum.flength - offset);
 -                      if (do_progress)
 +                      if (recv_progress)
                                show_progress(offset, total_size);
@@ -1165,7 +1171,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 +                      if (preserve_hard_links && file->link_u.links)
 +                              push_hlink_num(i);
                } else if (!recv_ok) {
-                       int msgtype = phase || read_batch ? FERROR : FINFO;
+                       enum logcode msgtype = phase || read_batch ? FERROR : FINFO;
                        if (msgtype == FERROR || verbose) {
 @@ -681,8 +678,8 @@ int recv_files(int f_in, struct file_lis
                                        errstr, fname, keptstr, redostr);
@@ -1197,7 +1203,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  }
 --- old/rsync.h
 +++ new/rsync.h
-@@ -169,10 +169,8 @@ enum msgcode {
+@@ -170,10 +170,8 @@ enum msgcode {
        MSG_DATA=0,     /* raw data on the multiplexed stream */
        MSG_ERROR=FERROR, MSG_INFO=FINFO, /* remote logging */
        MSG_LOG=FLOG, MSG_SOCKERR=FSOCKERR, /* sibling logging */
@@ -1208,7 +1214,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  };
  
  #include "errcode.h"
-@@ -329,6 +327,7 @@ enum msgcode {
+@@ -330,6 +328,7 @@ enum msgcode {
  #endif
  
  #include <assert.h>
@@ -1218,7 +1224,7 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
  
 --- old/util.c
 +++ new/util.c
-@@ -415,49 +415,6 @@ int robust_rename(char *from, char *to, 
+@@ -417,49 +417,6 @@ int robust_rename(const char *from, cons
        return -1;
  }
  
@@ -1266,5 +1272,5 @@ mailing list with your results, build changes, bug reports, etc.  Thanks!
 -}
 -
  /** Turn a user name into a uid */
- int name_to_uid(char *name, uid_t *uid)
+ int name_to_uid(const char *name, uid_t *uid)
  {