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:
-
- ./prepare-source
- ./configure (optional if already run)
- make
-
--- old/Makefile.in
+++ new/Makefile.in
-@@ -6,7 +6,7 @@ exec_prefix=@exec_prefix@
+@@ -7,7 +7,7 @@ exec_prefix=@exec_prefix@
bindir=@bindir@
mandir=@mandir@
/**
* Close all open sockets and files, allowing a (somewhat) graceful
* shutdown() of socket connections. This eliminates the abortive
-@@ -103,9 +99,6 @@ void _exit_cleanup(int code, const char
- }
- inside_cleanup++;
+@@ -98,9 +94,6 @@ NORETURN void _exit_cleanup(int code, co
+ static int exit_code = 0;
+ static int unmodified_code = 0;
- SIGACTION(SIGUSR1, SIG_IGN);
- SIGACTION(SIGUSR2, SIG_IGN);
-
- if (verbose > 3) {
- rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
- code, file, line);
-@@ -137,8 +130,6 @@ void _exit_cleanup(int code, const char
- 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 @@
#define RERR_MALLOC 22 /* error allocating core memory buffers */
--- old/generator.c
+++ new/generator.c
-@@ -67,7 +67,6 @@ extern OFF_T min_size;
+@@ -66,7 +66,6 @@ extern OFF_T min_size;
extern int io_error;
extern int allowed_lull;
extern int sock_f_out;
/* For calling delete_file() */
#define DEL_FORCE_RECURSE (1<<1) /* recurse even w/o --force */
#define DEL_TERSE (1<<3)
-@@ -443,8 +447,8 @@ static void sum_sizes_sqroot(struct sum_
+@@ -445,8 +449,8 @@ static void sum_sizes_sqroot(struct sum_
}
if (protocol_version < 27) {
s2length = SUM_LENGTH;
} else {
int32 c;
-@@ -454,7 +458,7 @@ static void sum_sizes_sqroot(struct sum_
- for (c = blength; c >>= 1 && b; b--) {}
+@@ -456,7 +460,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-- */
- s2length = MAX(s2length, csum_length);
s2length = MIN(s2length, SUM_LENGTH);
}
-@@ -488,7 +492,7 @@ static void generate_and_send_sums(int f
+@@ -490,7 +494,7 @@ static void generate_and_send_sums(int f
sum_sizes_sqroot(&sum, len);
write_sum_head(f_out, &sum);
return;
if (len > 0)
-@@ -507,7 +511,7 @@ static void generate_and_send_sums(int f
+@@ -509,7 +513,7 @@ static void generate_and_send_sums(int f
if (f_copy >= 0) {
full_write(f_copy, map, n1);
continue;
}
-@@ -1182,7 +1186,7 @@ static void recv_generator(char *fname,
+@@ -1205,7 +1209,7 @@ static void recv_generator(char *fname,
return;
}
return;
if (fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH)
-@@ -1237,7 +1241,7 @@ static void recv_generator(char *fname,
+@@ -1268,7 +1272,7 @@ static void recv_generator(char *fname,
goto notify_others;
}
if (!(backupptr = get_backup_name(fname))) {
close(fd);
return;
-@@ -1328,9 +1332,12 @@ void generate_files(int f_out, struct fi
+@@ -1359,9 +1363,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;
if (protocol_version >= 29) {
itemizing = 1;
maybe_ATTRS_REPORT = stdout_format_has_i ? 0 : ATTRS_REPORT;
-@@ -1358,7 +1365,7 @@ void generate_files(int f_out, struct fi
+@@ -1389,7 +1396,7 @@ void generate_files(int f_out, struct fi
do_delete_pass(flist);
do_progress = 0;
whole_file = 0;
if (verbose >= 2) {
rprintf(FINFO, "delta-transmission %s\n",
-@@ -1367,12 +1374,6 @@ void generate_files(int f_out, struct fi
+@@ -1398,12 +1405,6 @@ void generate_files(int f_out, struct fi
: "enabled");
}
for (i = 0; i < flist->count; i++) {
struct file_struct *file = flist->files[i];
-@@ -1416,23 +1417,34 @@ void generate_files(int f_out, struct fi
+@@ -1447,23 +1448,34 @@ void generate_files(int f_out, struct fi
delete_in_dir(NULL, NULL, NULL, NULL);
phase++;
if (local_name)
strlcpy(fbuf, local_name, sizeof fbuf);
else
-@@ -1444,27 +1456,43 @@ void generate_files(int f_out, struct fi
+@@ -1475,27 +1487,43 @@ void generate_files(int f_out, struct fi
phase++;
ignore_non_existing = save_ignore_non_existing;
ignore_existing = save_ignore_existing;
extern int csum_length;
extern int checksum_seed;
extern int protocol_version;
--extern int remove_sent_files;
+-extern int remove_source_files;
extern int preserve_hard_links;
extern char *filesfrom_host;
extern struct stats stats;
- exit_cleanup(RERR_STREAMIO);
- }
- read_loop(fd, buf, 4);
-- if (remove_sent_files)
+- if (remove_source_files)
- decrement_active_files(IVAL(buf,0));
- flist_ndx_push(&redo_list, IVAL(buf,0));
- break;
- exit_cleanup(RERR_STREAMIO);
- }
- read_loop(fd, buf, len);
-- if (remove_sent_files) {
+- if (remove_source_files) {
- decrement_active_files(IVAL(buf,0));
- send_msg(MSG_SUCCESS, buf, len);
- }
if (io_filesfrom_f_out >= 0) {
if (io_filesfrom_buflen) {
if (FD_ISSET(io_filesfrom_f_out, &w_fds)) {
-@@ -841,6 +791,8 @@ static void readfd(int fd, char *buffer,
+@@ -847,6 +797,8 @@ static void readfd(int fd, char *buffer,
}
if (fd == write_batch_monitor_in) {
if ((size_t)write(batch_fd, buffer, total) != total)
exit_cleanup(RERR_FILEIO);
}
-@@ -1102,7 +1054,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1115,7 +1067,6 @@ static void writefd_unbuffered(int fd,ch
* to grab any messages they sent before they died. */
while (fd == sock_f_out && io_multiplexing_in) {
set_io_timeout(30);
readfd_unbuffered(sock_f_in, io_filesfrom_buf,
sizeof io_filesfrom_buf);
}
-@@ -1113,7 +1064,7 @@ static void writefd_unbuffered(int fd,ch
+@@ -1126,7 +1077,7 @@ static void writefd_unbuffered(int fd,ch
defer_forwarding_messages = 1;
if (fd == sock_f_out) {
last_io_out = time(NULL);
sleep_for_bwlimit(cnt);
}
-@@ -1123,23 +1074,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1136,23 +1087,6 @@ static void writefd_unbuffered(int fd,ch
no_flush--;
}
/**
* Write an message to a multiplexed stream. If this fails then rsync
* exits.
-@@ -1165,14 +1099,15 @@ static void mplex_write(enum msgcode cod
+@@ -1178,14 +1112,15 @@ static void mplex_write(enum msgcode cod
defer_forwarding_messages = 1;
writefd_unbuffered(sock_f_out, buf, len);
defer_forwarding_messages = 0;
}
}
- 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();
if (!iobuf_out_cnt || no_flush)
return;
-@@ -1186,11 +1121,6 @@ void io_flush(int flush_it_all)
+@@ -1199,11 +1134,6 @@ void io_flush(int flush_it_all)
static void writefd(int fd,char *buf,size_t len)
{
if (fd == sock_f_out)
stats.total_written += len;
-@@ -1396,9 +1326,3 @@ void start_write_batch(int fd)
+@@ -1409,9 +1339,3 @@ void start_write_batch(int fd)
else
write_batch_monitor_in = fd;
}
extern int allow_8bit_chars;
extern int protocol_version;
extern int preserve_times;
-@@ -72,7 +71,6 @@ struct {
+@@ -75,7 +74,6 @@ struct {
{ RERR_IPC , "error in IPC code" },
{ RERR_CRASHED , "sibling process crashed" },
{ RERR_TERMINATED , "sibling process terminated abnormally" },
{ RERR_SIGNAL , "received SIGINT, SIGTERM, or SIGHUP" },
{ RERR_WAITCHILD , "waitpid() failed" },
{ RERR_MALLOC , "error allocating core memory buffers" },
-@@ -224,8 +222,8 @@ void rwrite(enum logcode code, char *buf
+@@ -241,8 +239,8 @@ void rwrite(enum logcode code, char *buf
if (len < 0)
exit_cleanup(RERR_MESSAGEIO);
-extern int am_generator;
extern int am_daemon;
extern int blocking_io;
- extern int remove_sent_files;
-@@ -93,9 +92,20 @@ struct pid_status {
+ extern int remove_source_files;
+@@ -96,9 +95,20 @@ struct pid_status {
static time_t starttime, endtime;
static int64 total_read, total_written;
/* Works like waitpid(), but if we already harvested the child pid in our
* remember_children(), we succeed instead of returning an error. */
pid_t wait_process(pid_t pid, int *status_ptr, int flags)
-@@ -172,7 +182,7 @@ static void handle_stats(int f)
+@@ -175,7 +185,7 @@ static void handle_stats(int f)
show_flist_stats();
}
return;
if (am_daemon) {
-@@ -647,12 +657,30 @@ static void do_server_sender(int f_in, i
+@@ -683,12 +693,30 @@ static void do_server_sender(int f_in, i
exit_cleanup(0);
}
/* The receiving side mustn't obey this, or an existing symlink that
* points to an identical file won't be replaced by the referent. */
-@@ -661,70 +689,16 @@ static int do_recv(int f_in,int f_out,st
+@@ -697,70 +725,16 @@ static int do_recv(int f_in,int f_out,st
if (preserve_hard_links)
init_hard_links();
generate_files(f_out, flist, local_name);
handle_stats(-1);
-@@ -735,10 +709,13 @@ static int do_recv(int f_in,int f_out,st
+@@ -771,10 +745,13 @@ static int do_recv(int f_in,int f_out,st
}
io_flush(FULL_FLUSH);
}
-@@ -1140,22 +1117,6 @@ static int start_client(int argc, char *
+@@ -1176,22 +1153,6 @@ static int start_client(int argc, char *
return ret;
}
RETSIGTYPE remember_children(UNUSED(int val))
{
#ifdef WNOHANG
-@@ -1247,8 +1208,6 @@ int main(int argc,char *argv[])
+@@ -1283,8 +1244,6 @@ int main(int argc,char *argv[])
# endif
sigact.sa_flags = SA_NOCLDSTOP;
#endif
int keep_partial = 0;
int safe_symlinks = 0;
int copy_unsafe_links = 0;
-@@ -1304,6 +1304,7 @@ int parse_arguments(int *argc, const cha
+@@ -1302,6 +1302,7 @@ int parse_arguments(int *argc, const cha
if (do_progress && !verbose && !log_before_transfer && !am_server)
verbose = 1;
extern int log_before_transfer;
extern int stdout_format_has_i;
extern int logfile_format_has_i;
-@@ -154,7 +154,7 @@ static int receive_data(int f_in, char *
+@@ -157,7 +157,7 @@ static int receive_data(int f_in, char *
if (sum.remainder)
sum.flength -= sum.blength - sum.remainder;
for (j = CHUNK_SIZE; j < sum.flength; j += CHUNK_SIZE) {
show_progress(offset, total_size);
sum_update(map_ptr(mapbuf, offset, CHUNK_SIZE),
CHUNK_SIZE);
-@@ -162,7 +162,7 @@ static int receive_data(int f_in, char *
+@@ -165,7 +165,7 @@ static int receive_data(int f_in, char *
}
if (offset < sum.flength) {
int32 len = sum.flength - offset;
show_progress(offset, total_size);
sum_update(map_ptr(mapbuf, offset, len), len);
offset = sum.flength;
-@@ -175,7 +175,7 @@ static int receive_data(int f_in, char *
+@@ -178,7 +178,7 @@ static int receive_data(int f_in, char *
}
while ((i = recv_token(f_in, &data)) != 0) {
show_progress(offset, total_size);
if (i > 0) {
-@@ -245,7 +245,7 @@ static int receive_data(int f_in, char *
+@@ -248,7 +248,7 @@ static int receive_data(int f_in, char *
ftruncate(fd, offset);
#endif
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
-@@ -296,12 +296,12 @@ static void handle_delayed_updates(struc
+@@ -299,12 +299,12 @@ static void handle_delayed_updates(struc
"rename failed for %s (from %s)",
full_fname(fname), partialptr);
} else {
-- if (remove_sent_files
+- if (remove_source_files
- || (preserve_hard_links
- && file->link_u.links)) {
-+ if (remove_sent_files) {
++ if (remove_source_files) {
SIVAL(numbuf, 0, i);
send_msg(MSG_SUCCESS,numbuf,4);
}
handle_partial_dir(partialptr, PDIR_DELETE);
}
}
-@@ -352,11 +352,6 @@ int recv_files(int f_in, struct file_lis
+@@ -355,11 +355,6 @@ int recv_files(int f_in, struct file_lis
if (verbose > 2)
rprintf(FINFO,"recv_files(%d) starting\n",flist->count);
if (delay_updates)
delayed_bits = bitbag_create(flist->count);
-@@ -377,7 +372,7 @@ int recv_files(int f_in, struct file_lis
+@@ -382,7 +377,7 @@ int recv_files(int f_in, struct file_lis
rprintf(FINFO, "recv_files phase=%d\n", phase);
if (phase == 2 && delay_updates)
handle_delayed_updates(flist, local_name);
if (keep_partial && !partial_dir)
make_backups = 0; /* prevents double backup */
if (append_mode) {
-@@ -597,7 +592,7 @@ int recv_files(int f_in, struct file_lis
+@@ -607,7 +602,7 @@ int recv_files(int f_in, struct file_lis
/* log the transfer */
if (log_before_transfer)
- log_item(FNAME, file, &initial_stats, iflags, NULL);
+ log_item(FCLIENT, file, &initial_stats, iflags, NULL);
- else if (!am_server && verbose && do_progress)
+ else if (!am_server && verbose && recv_progress)
rprintf(FINFO, "%s\n", fname);
/* recv file data */
-@@ -644,11 +639,13 @@ int recv_files(int f_in, struct file_lis
+@@ -654,11 +649,13 @@ int recv_files(int f_in, struct file_lis
cleanup_disable();
if (recv_ok > 0) {
-- if (remove_sent_files
+- if (remove_source_files
- || (preserve_hard_links && file->link_u.links)) {
-+ if (remove_sent_files) {
++ if (remove_source_files) {
+ decrement_active_files(i);
SIVAL(numbuf, 0, i);
send_msg(MSG_SUCCESS, numbuf, 4);
} else if (!recv_ok) {
int msgtype = phase || read_batch ? FERROR : FINFO;
if (msgtype == FERROR || verbose) {
-@@ -671,8 +668,8 @@ int recv_files(int f_in, struct file_lis
+@@ -681,8 +678,8 @@ int recv_files(int f_in, struct file_lis
errstr, fname, keptstr, redostr);
}
if (!phase) {
}
--- old/rsync.c
+++ new/rsync.c
-@@ -40,7 +40,6 @@ extern int omit_dir_times;
+@@ -39,7 +39,6 @@ extern int omit_dir_times;
extern int am_root;
extern int am_server;
extern int am_sender;
extern int am_starting_up;
extern int allow_8bit_chars;
extern int preserve_uid;
-@@ -302,5 +301,5 @@ const char *who_am_i(void)
+@@ -305,5 +304,5 @@ const char *who_am_i(void)
{
if (am_starting_up)
return am_server ? "server" : "client";
};
#include "errcode.h"
-@@ -323,6 +321,7 @@ enum msgcode {
+@@ -329,6 +327,7 @@ enum msgcode {
#endif
#include <assert.h>