Fixed failing hunks.
[rsync/rsync-patches.git] / threaded-receiver.diff
index 8a5ea35..5286c54 100644 (file)
@@ -18,10 +18,10 @@ 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!
 
-After applying this patch, run these commands for a successful build:
+To use this patch, run these commands for a successful build:
 
-    ./prepare-source
-    ./configure                      (optional if already run)
+    patch -p1 <patches/threaded-receiver.diff
+    ./configure
     make
 
 --- old/Makefile.in
@@ -49,24 +49,24 @@ After applying this patch, run these commands for a successful build:
   * Close all open sockets and files, allowing a (somewhat) graceful
   * shutdown() of socket connections.  This eliminates the abortive
 @@ -98,9 +94,6 @@ NORETURN void _exit_cleanup(int code, co
- {
-       int ocode = code;
+       static int exit_code = 0;
+       static int unmodified_code = 0;
  
 -      SIGACTION(SIGUSR1, SIG_IGN);
 -      SIGACTION(SIGUSR2, SIG_IGN);
 -
-       in_exit_cleanup = 1;
-       if (verbose > 3) {
-@@ -133,8 +126,6 @@ NORETURN void _exit_cleanup(int code, co
-       io_flush(FULL_FLUSH);
-       if (cleanup_fname)
-               do_unlink(cleanup_fname);
--      if (code)
--              kill_all(SIGUSR1);
-       if (cleanup_pid && cleanup_pid == getpid()) {
-               char *pidf = lp_pid_file();
-               if (pidf && *pidf)
+       if (exit_code) /* Preserve first error code when recursing. */
+               code = exit_code;
+@@ -157,8 +150,6 @@ NORETURN void _exit_cleanup(int code, co
+               if (cleanup_fname)
+                       do_unlink(cleanup_fname);
+-              if (code)
+-                      kill_all(SIGUSR1);
+               if (cleanup_pid && cleanup_pid == getpid()) {
+                       char *pidf = lp_pid_file();
+                       if (pidf && *pidf)
 --- old/errcode.h
 +++ new/errcode.h
 @@ -37,7 +37,6 @@
@@ -96,10 +96,10 @@ After applying this patch, run these commands for a successful build:
 +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() */
+ #define DEL_RECURSE           (1<<1) /* recurse */
+@@ -477,8 +481,8 @@ static void sum_sizes_sqroot(struct sum_
        }
  
        if (protocol_version < 27) {
@@ -110,7 +110,7 @@ After applying this patch, run these commands for a successful build:
                s2length = SUM_LENGTH;
        } else {
                int32 c;
-@@ -456,7 +460,7 @@ static void sum_sizes_sqroot(struct sum_
+@@ -488,7 +492,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-- */
@@ -119,7 +119,7 @@ After applying this patch, run these commands for a successful build:
                s2length = MIN(s2length, SUM_LENGTH);
        }
  
-@@ -490,7 +494,7 @@ static void generate_and_send_sums(int f
+@@ -522,7 +526,7 @@ static void generate_and_send_sums(int f
        sum_sizes_sqroot(&sum, len);
        write_sum_head(f_out, &sum);
  
@@ -128,7 +128,7 @@ After applying this patch, run these commands for a successful build:
                return;
  
        if (len > 0)
-@@ -509,7 +513,7 @@ static void generate_and_send_sums(int f
+@@ -541,7 +545,7 @@ static void generate_and_send_sums(int f
  
                if (f_copy >= 0) {
                        full_write(f_copy, map, n1);
@@ -137,7 +137,7 @@ After applying this patch, run these commands for a successful build:
                                continue;
                }
  
-@@ -1205,7 +1209,7 @@ static void recv_generator(char *fname, 
+@@ -1316,7 +1320,7 @@ static void recv_generator(char *fname, 
                return;
        }
  
@@ -146,7 +146,7 @@ After applying this patch, run these commands for a successful build:
                return;
  
        if (fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH)
-@@ -1268,7 +1272,7 @@ static void recv_generator(char *fname, 
+@@ -1379,7 +1383,7 @@ static void recv_generator(char *fname, 
                goto notify_others;
        }
  
@@ -155,7 +155,7 @@ After applying this patch, run these commands for a successful build:
                if (!(backupptr = get_backup_name(fname))) {
                        close(fd);
                        return;
-@@ -1359,9 +1363,12 @@ void generate_files(int f_out, struct fi
+@@ -1470,9 +1474,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;
@@ -169,7 +169,7 @@ After applying this patch, run these commands for a successful build:
        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
+@@ -1500,7 +1507,7 @@ void generate_files(int f_out, struct fi
                do_delete_pass(flist);
        do_progress = 0;
  
@@ -178,7 +178,7 @@ After applying this patch, run these commands for a successful build:
                whole_file = 0;
        if (verbose >= 2) {
                rprintf(FINFO, "delta-transmission %s\n",
-@@ -1398,12 +1405,6 @@ void generate_files(int f_out, struct fi
+@@ -1509,12 +1516,6 @@ void generate_files(int f_out, struct fi
                        : "enabled");
        }
  
@@ -191,7 +191,7 @@ After applying this patch, run these commands for a successful build:
        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
+@@ -1558,23 +1559,34 @@ void generate_files(int f_out, struct fi
                delete_in_dir(NULL, NULL, NULL, NULL);
  
        phase++;
@@ -232,7 +232,7 @@ After applying this patch, run these commands for a successful build:
                if (local_name)
                        strlcpy(fbuf, local_name, sizeof fbuf);
                else
-@@ -1475,27 +1487,43 @@ void generate_files(int f_out, struct fi
+@@ -1586,27 +1598,43 @@ void generate_files(int f_out, struct fi
        phase++;
        ignore_non_existing = save_ignore_non_existing;
        ignore_existing = save_ignore_existing;
@@ -719,7 +719,8 @@ After applying this patch, run these commands for a successful build:
        }
  }
  
- void io_flush(int flush_it_all)
+-void io_flush(int flush_it_all)
++void io_flush(UNUSED(int flush_it_all))
  {
 -      msg2genr_flush(flush_it_all);
 -      msg2sndr_flush();
@@ -760,7 +761,7 @@ After applying this patch, run these commands for a successful build:
  extern int allow_8bit_chars;
  extern int protocol_version;
  extern int preserve_times;
-@@ -76,7 +75,6 @@ struct {
+@@ -75,7 +74,6 @@ struct {
        { RERR_IPC        , "error in IPC code" },
        { RERR_CRASHED    , "sibling process crashed" },
        { RERR_TERMINATED , "sibling process terminated abnormally" },
@@ -768,9 +769,9 @@ After applying this patch, run these commands for a successful build:
        { RERR_SIGNAL     , "received SIGINT, SIGTERM, or SIGHUP" },
        { RERR_WAITCHILD  , "waitpid() failed" },
        { RERR_MALLOC     , "error allocating core memory buffers" },
-@@ -250,8 +248,8 @@ void rwrite(enum logcode code, char *buf
+@@ -241,8 +239,8 @@ void rwrite(enum logcode code, char *buf
        if (len < 0)
-               EXIT_OR_RETURN(RERR_MESSAGEIO);
+               exit_cleanup(RERR_MESSAGEIO);
  
 -      if (am_server && msg_fd_out >= 0) {
 -              /* Pass the message to our sibling. */
@@ -859,6 +860,13 @@ After applying this patch, run these commands for a successful build:
  
 -      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;
@@ -867,13 +875,6 @@ After applying this patch, run these commands for a successful build:
                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)
@@ -1035,7 +1036,7 @@ After applying this patch, run these commands for a successful build:
  int keep_partial = 0;
  int safe_symlinks = 0;
  int copy_unsafe_links = 0;
-@@ -1299,6 +1299,7 @@ int parse_arguments(int *argc, const cha
+@@ -1306,6 +1306,7 @@ int parse_arguments(int *argc, const cha
  
        if (do_progress && !verbose && !log_before_transfer && !am_server)
                verbose = 1;
@@ -1202,7 +1203,7 @@ After applying this patch, run these commands for a successful build:
  }
 --- 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 */
@@ -1213,7 +1214,7 @@ After applying this patch, run these commands for a successful build:
  };
  
  #include "errcode.h"
-@@ -329,6 +327,7 @@ enum msgcode {
+@@ -330,6 +328,7 @@ enum msgcode {
  #endif
  
  #include <assert.h>