mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-01-20 12:58:00 -05:00
Added a debug-helping option, --msgs2stderr, than should help all
messages to be seen in a situation where rsync is dying (as long as stderr is a viable output method for the remote rsync).
This commit is contained in:
7
log.c
7
log.c
@@ -36,6 +36,7 @@ extern int allow_8bit_chars;
|
||||
extern int protocol_version;
|
||||
extern int always_checksum;
|
||||
extern int preserve_times;
|
||||
extern int msgs2stderr;
|
||||
extern int uid_ndx;
|
||||
extern int gid_ndx;
|
||||
extern int stdout_format_has_i;
|
||||
@@ -257,6 +258,11 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
|
||||
if (len < 0)
|
||||
exit_cleanup(RERR_MESSAGEIO);
|
||||
|
||||
if (msgs2stderr && code != FLOG) {
|
||||
f = stderr;
|
||||
goto output_msg;
|
||||
}
|
||||
|
||||
if (am_server && msg_fd_out >= 0) {
|
||||
assert(!is_utf8);
|
||||
/* Pass the message to our sibling. */
|
||||
@@ -323,6 +329,7 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
|
||||
exit_cleanup(RERR_MESSAGEIO);
|
||||
}
|
||||
|
||||
output_msg:
|
||||
if (output_needs_newline) {
|
||||
fputc('\n', f);
|
||||
output_needs_newline = 0;
|
||||
|
||||
3
main.c
3
main.c
@@ -43,6 +43,7 @@ extern int output_needs_newline;
|
||||
extern int need_messages_from_generator;
|
||||
extern int kluge_around_eof;
|
||||
extern int got_xfer_error;
|
||||
extern int msgs2stderr;
|
||||
extern int module_id;
|
||||
extern int copy_links;
|
||||
extern int copy_dirlinks;
|
||||
@@ -860,7 +861,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
|
||||
char *local_name = NULL;
|
||||
int negated_levels;
|
||||
|
||||
if (filesfrom_fd >= 0) {
|
||||
if (filesfrom_fd >= 0 && !msgs2stderr) {
|
||||
/* We can't mix messages with files-from data on the socket,
|
||||
* so temporarily turn off info/debug messages. */
|
||||
negate_output_levels();
|
||||
|
||||
@@ -83,6 +83,7 @@ int am_starting_up = 1;
|
||||
int relative_paths = -1;
|
||||
int implied_dirs = 1;
|
||||
int numeric_ids = 0;
|
||||
int msgs2stderr = 0;
|
||||
int allow_8bit_chars = 0;
|
||||
int force_delete = 0;
|
||||
int io_timeout = 0;
|
||||
@@ -795,6 +796,7 @@ static struct poptOption long_options[] = {
|
||||
{"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 },
|
||||
{"info", 0, POPT_ARG_STRING, 0, OPT_INFO, 0, 0 },
|
||||
{"debug", 0, POPT_ARG_STRING, 0, OPT_DEBUG, 0, 0 },
|
||||
{"msgs2stderr", 0, POPT_ARG_NONE, &msgs2stderr, 0, 0, 0 },
|
||||
{"quiet", 'q', POPT_ARG_NONE, 0, 'q', 0, 0 },
|
||||
{"motd", 0, POPT_ARG_VAL, &output_motd, 1, 0, 0 },
|
||||
{"no-motd", 0, POPT_ARG_VAL, &output_motd, 0, 0, 0 },
|
||||
|
||||
7
rsync.c
7
rsync.c
@@ -45,6 +45,7 @@ extern int gid_ndx;
|
||||
extern int inc_recurse;
|
||||
extern int inplace;
|
||||
extern int flist_eof;
|
||||
extern int msgs2stderr;
|
||||
extern int keep_dirlinks;
|
||||
extern int make_backups;
|
||||
extern struct file_list *cur_flist, *first_flist, *dir_flist;
|
||||
@@ -278,13 +279,15 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
|
||||
rprintf(FINFO, "[%s] receiving flist for dir %d\n",
|
||||
who_am_i(), ndx);
|
||||
}
|
||||
negate_output_levels(); /* turn off all info/debug output */
|
||||
if (!msgs2stderr)
|
||||
negate_output_levels(); /* turn off all info/debug output */
|
||||
send_msg_int(MSG_FLIST, ndx);
|
||||
start_flist_forward(f_in);
|
||||
flist = recv_file_list(f_in);
|
||||
flist->parent_ndx = ndx;
|
||||
stop_flist_forward();
|
||||
negate_output_levels(); /* restore info/debug output */
|
||||
if (!msgs2stderr)
|
||||
negate_output_levels(); /* restore info/debug output */
|
||||
}
|
||||
|
||||
iflags = protocol_version >= 29 ? read_shortint(f_in)
|
||||
|
||||
@@ -9,21 +9,23 @@
|
||||
|
||||
hands_setup
|
||||
|
||||
DEBUG_OPTS="--debug=all5,deltasum0 --msgs2stderr"
|
||||
|
||||
# Main script starts here
|
||||
|
||||
runtest "basic operation" 'checkit "$RSYNC -av \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
|
||||
ln "$fromdir/filelist" "$fromdir/dir"
|
||||
runtest "hard links" 'checkit "$RSYNC -avH --debug=all5 \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
runtest "hard links" 'checkit "$RSYNC -avH $DEBUG_OPTS \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
|
||||
rm "$todir/text"
|
||||
runtest "one file" 'checkit "$RSYNC -avH --debug=hlink5 \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
runtest "one file" 'checkit "$RSYNC -avH $DEBUG_OPTS \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
|
||||
echo "extra line" >> "$todir/text"
|
||||
runtest "extra data" 'checkit "$RSYNC -avH --debug=hlink5 --no-whole-file \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
runtest "extra data" 'checkit "$RSYNC -avH $DEBUG_OPTS --no-whole-file \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
|
||||
cp "$fromdir/text" "$todir/ThisShouldGo"
|
||||
runtest " --delete" 'checkit "$RSYNC --delete -avH --debug=hlink5 \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
runtest " --delete" 'checkit "$RSYNC --delete -avH $DEBUG_OPTS \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
|
||||
|
||||
cd "$tmpdir"
|
||||
rm -rf to from/*dir
|
||||
|
||||
Reference in New Issue
Block a user