CPPFLAGS=@CPPFLAGS@
--- old/cleanup.c
+++ new/cleanup.c
-@@ -28,10 +28,6 @@ extern int keep_partial;
- extern int log_got_error;
+@@ -31,10 +31,6 @@ extern int log_got_error;
extern char *partial_dir;
+ extern char *logfile_name;
-#ifdef HAVE_SIGACTION
-static struct sigaction sigact;
/**
* Close all open sockets and files, allowing a (somewhat) graceful
* shutdown() of socket connections. This eliminates the abortive
-@@ -100,9 +96,6 @@ void _exit_cleanup(int code, const char
+@@ -103,9 +99,6 @@ void _exit_cleanup(int code, const char
}
inside_cleanup++;
if (verbose > 3) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
code, file, line);
-@@ -134,8 +127,6 @@ void _exit_cleanup(int code, const char
+@@ -137,8 +130,6 @@ void _exit_cleanup(int code, const char
io_flush(FULL_FLUSH);
if (cleanup_fname)
do_unlink(cleanup_fname);
continue;
}
-@@ -1184,7 +1188,7 @@ static void recv_generator(char *fname,
+@@ -1185,7 +1189,7 @@ static void recv_generator(char *fname,
return;
}
return;
if (fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH)
-@@ -1239,7 +1243,7 @@ static void recv_generator(char *fname,
+@@ -1240,7 +1244,7 @@ static void recv_generator(char *fname,
goto notify_others;
}
if (!(backupptr = get_backup_name(fname))) {
close(fd);
return;
-@@ -1330,9 +1334,12 @@ void generate_files(int f_out, struct fi
+@@ -1331,9 +1335,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 = log_format_has_i ? 0 : ATTRS_REPORT;
-@@ -1360,7 +1367,7 @@ void generate_files(int f_out, struct fi
+@@ -1361,7 +1368,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",
-@@ -1369,12 +1376,6 @@ void generate_files(int f_out, struct fi
+@@ -1370,12 +1377,6 @@ void generate_files(int f_out, struct fi
: "enabled");
}
for (i = 0; i < flist->count; i++) {
struct file_struct *file = flist->files[i];
-@@ -1418,23 +1419,34 @@ void generate_files(int f_out, struct fi
+@@ -1419,23 +1420,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
-@@ -1446,27 +1458,43 @@ void generate_files(int f_out, struct fi
+@@ -1447,27 +1459,43 @@ void generate_files(int f_out, struct fi
phase++;
ignore_non_existing = save_ignore_non_existing;
ignore_existing = save_ignore_existing;
static void read_msg_fd(void)
{
char buf[2048];
-@@ -244,58 +242,6 @@ static void read_msg_fd(void)
+@@ -244,51 +242,6 @@ static void read_msg_fd(void)
tag = (tag >> 24) - MPLEX_BASE;
switch (tag) {
- exit_cleanup(RERR_STREAMIO);
- }
- read_loop(fd, buf, len);
-- if (defer_forwarding_messages)
-- msg_list_add(&msg2sndr, MSG_DELETED, buf, len);
-- else
-- io_multiplex_write(MSG_DELETED, buf, len);
+- send_msg(MSG_DELETED, buf, len);
- break;
- case MSG_SUCCESS:
- if (len != 4 || !am_generator) {
- read_loop(fd, buf, len);
- if (remove_sent_files) {
- decrement_active_files(IVAL(buf,0));
-- if (defer_forwarding_messages)
-- msg_list_add(&msg2sndr, MSG_SUCCESS, buf, len);
-- else
-- io_multiplex_write(MSG_SUCCESS, buf, len);
+- send_msg(MSG_SUCCESS, buf, len);
- }
- if (preserve_hard_links)
- flist_ndx_push(&hlink_list, IVAL(buf,0));
- exit_cleanup(RERR_STREAMIO);
- }
- close_multiplexing_out();
-- defer_forwarding_messages = 0;
- /* FALL THROUGH */
case MSG_INFO:
case MSG_ERROR:
case MSG_LOG:
-@@ -304,11 +250,7 @@ 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 && tag != MSG_LOG)
-- msg_list_add(&msg2sndr, tag, buf, n);
-- else
-- rwrite((enum logcode)tag, buf, n);
-+ rwrite((enum logcode)tag, buf, n);
- len -= n;
- }
- break;
-@@ -343,70 +285,76 @@ void decrement_active_files(int ndx)
+@@ -332,75 +285,80 @@ void decrement_active_files(int ndx)
active_bytecnt -= the_file_list->files[ndx]->length;
}
+ no_flush--;
}
- void send_msg(enum msgcode code, char *buf, int len)
+ int send_msg(enum msgcode code, char *buf, int len)
{
- if (msg_fd_out < 0) {
-+ if (am_receiver())
-+ msg_list_add(code, buf, len);
-+ else
- io_multiplex_write(code, buf, len);
-- return;
-- }
++ if (!am_receiver()) {
+ if (!defer_forwarding_messages)
+ return io_multiplex_write(code, buf, len);
+ if (!io_multiplexing_out)
+ return 0;
+- msg_list_add(&msg2sndr, code, buf, len);
+- return 1;
+ }
- msg_list_add(&msg2genr, code, buf, len);
- msg2genr_flush(NORMAL_FLUSH);
++ msg_list_add(code, buf, len);
+ return 1;
}
-int get_redo_num(int itemizing, enum logcode code)
return flist_ndx_pop(&hlink_list);
}
-@@ -486,11 +434,6 @@ static int read_timeout(int fd, char *bu
+@@ -480,11 +438,6 @@ static int read_timeout(int fd, char *bu
FD_ZERO(&r_fds);
FD_ZERO(&w_fds);
FD_SET(fd, &r_fds);
if (io_filesfrom_f_out >= 0) {
int new_fd;
if (io_filesfrom_buflen == 0) {
-@@ -523,9 +466,6 @@ static int read_timeout(int fd, char *bu
+@@ -517,9 +470,6 @@ static int read_timeout(int fd, char *bu
continue;
}
if (io_filesfrom_f_out >= 0) {
if (io_filesfrom_buflen) {
if (FD_ISSET(io_filesfrom_f_out, &w_fds)) {
-@@ -847,6 +787,8 @@ static void readfd(int fd, char *buffer,
+@@ -841,6 +791,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);
}
-@@ -1108,7 +1050,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1102,7 +1054,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);
}
-@@ -1119,7 +1060,7 @@ static void writefd_unbuffered(int fd,ch
+@@ -1113,7 +1064,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);
}
-@@ -1129,32 +1070,6 @@ static void writefd_unbuffered(int fd,ch
+@@ -1123,23 +1074,6 @@ static void writefd_unbuffered(int fd,ch
no_flush--;
}
-
- while (msg2sndr.head && io_multiplexing_out) {
- struct msg_list_item *m = msg2sndr.head;
-- int tag = *((uchar*)m->buf+3) - MPLEX_BASE;
- if (!(msg2sndr.head = m->next))
- msg2sndr.tail = NULL;
+- stats.total_written += m->len;
- defer_forwarding_messages = 1;
-- 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;
-- }
+- writefd_unbuffered(sock_f_out, m->buf, m->len);
- defer_forwarding_messages = 0;
- free(m);
- }
/**
* Write an message to a multiplexed stream. If this fails then rsync
* exits.
-@@ -1180,14 +1095,15 @@ static void mplex_write(enum msgcode cod
+@@ -1165,14 +1099,15 @@ static void mplex_write(enum msgcode cod
defer_forwarding_messages = 1;
writefd_unbuffered(sock_f_out, buf, len);
defer_forwarding_messages = 0;
if (!iobuf_out_cnt || no_flush)
return;
-@@ -1201,11 +1117,6 @@ void io_flush(int flush_it_all)
+@@ -1186,11 +1121,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;
-@@ -1411,9 +1322,3 @@ void start_write_batch(int fd)
+@@ -1396,9 +1326,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;
-@@ -71,7 +70,6 @@ struct {
+@@ -72,7 +71,6 @@ struct {
{ RERR_IPC , "error in IPC code" },
{ RERR_CRASHED , "sibling process crashed" },
{ RERR_TERMINATED , "sibling process terminated abnormally" },
{ RERR_WAITCHILD , "waitpid() failed" },
{ RERR_MALLOC , "error allocating core memory buffers" },
@@ -224,8 +222,8 @@ void rwrite(enum logcode code, char *buf
- if (quiet && code == FINFO)
- return;
+ if (len < 0)
+ exit_cleanup(RERR_MESSAGEIO);
- if (am_server && msg_fd_out >= 0) {
- /* Pass the message to our sibling. */
extern int am_daemon;
extern int blocking_io;
extern int remove_sent_files;
-@@ -91,9 +90,20 @@ struct pid_status {
+@@ -93,9 +92,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)
-@@ -170,7 +180,7 @@ static void handle_stats(int f)
+@@ -172,7 +182,7 @@ static void handle_stats(int f)
show_flist_stats();
}
return;
if (am_daemon) {
-@@ -634,12 +644,30 @@ static void do_server_sender(int f_in, i
+@@ -647,12 +657,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. */
-@@ -648,70 +676,16 @@ static int do_recv(int f_in,int f_out,st
+@@ -661,70 +689,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);
-@@ -722,10 +696,13 @@ static int do_recv(int f_in,int f_out,st
+@@ -735,10 +709,13 @@ static int do_recv(int f_in,int f_out,st
}
io_flush(FULL_FLUSH);
}
-@@ -1103,22 +1080,6 @@ static int start_client(int argc, char *
+@@ -1140,22 +1117,6 @@ static int start_client(int argc, char *
return ret;
}
RETSIGTYPE remember_children(UNUSED(int val))
{
#ifdef WNOHANG
-@@ -1210,8 +1171,6 @@ int main(int argc,char *argv[])
+@@ -1247,8 +1208,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;
-@@ -1294,6 +1294,7 @@ int parse_arguments(int *argc, const cha
+@@ -1301,6 +1301,7 @@ int parse_arguments(int *argc, const cha
if (do_progress && !verbose && !log_before_transfer && !am_server)
verbose = 1;
exit_cleanup(RERR_IPC);
--- old/receiver.c
+++ new/receiver.c
-@@ -26,7 +26,7 @@ extern int verbose;
+@@ -25,7 +25,7 @@
+ extern int verbose;
extern int do_xfers;
- extern int am_daemon;
extern int am_server;
-extern int do_progress;
+extern int recv_progress;
extern int log_before_transfer;
extern int log_format_has_i;
- extern int daemon_log_format_has_i;
-@@ -155,7 +155,7 @@ static int receive_data(int f_in, char *
+ extern int logfile_format_has_i;
+@@ -154,7 +154,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);
-@@ -163,7 +163,7 @@ static int receive_data(int f_in, char *
+@@ -162,7 +162,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;
-@@ -176,7 +176,7 @@ static int receive_data(int f_in, char *
+@@ -175,7 +175,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) {
-@@ -244,7 +244,7 @@ static int receive_data(int f_in, char *
+@@ -243,7 +243,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) {
-@@ -295,12 +295,12 @@ static void handle_delayed_updates(struc
+@@ -294,12 +294,12 @@ static void handle_delayed_updates(struc
"rename failed for %s (from %s)",
full_fname(fname), partialptr);
} else {
handle_partial_dir(partialptr, PDIR_DELETE);
}
}
-@@ -351,11 +351,6 @@ int recv_files(int f_in, struct file_lis
+@@ -349,11 +349,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);
-@@ -376,7 +371,7 @@ int recv_files(int f_in, struct file_lis
+@@ -374,7 +369,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) {
-@@ -598,7 +593,7 @@ int recv_files(int f_in, struct file_lis
+@@ -596,7 +591,7 @@ int recv_files(int f_in, struct file_lis
/* log the transfer */
if (log_before_transfer)
log_item(file, &initial_stats, iflags, NULL);
rprintf(FINFO, "%s\n", fname);
/* recv file data */
-@@ -641,11 +636,13 @@ int recv_files(int f_in, struct file_lis
+@@ -644,11 +639,13 @@ int recv_files(int f_in, struct file_lis
cleanup_disable();
if (recv_ok > 0) {
} else if (!recv_ok) {
int msgtype = phase || read_batch ? FERROR : FINFO;
if (msgtype == FERROR || verbose) {
-@@ -668,8 +665,8 @@ int recv_files(int f_in, struct file_lis
+@@ -671,8 +668,8 @@ int recv_files(int f_in, struct file_lis
errstr, fname, keptstr, redostr);
}
if (!phase) {
}
--- old/rsync.h
+++ new/rsync.h
-@@ -168,10 +168,8 @@ enum msgcode {
+@@ -169,10 +169,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 */
};
#include "errcode.h"
-@@ -322,6 +320,7 @@ enum msgcode {
+@@ -323,6 +321,7 @@ enum msgcode {
#endif
#include <assert.h>