diff options
author | Wayne Davison <wayned@samba.org> | 2009-11-07 00:39:50 -0800 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2009-11-07 01:22:11 -0800 |
commit | f9185203ee03152001530db5624a2b8c93e1ea94 (patch) | |
tree | 8b1fb3dff27b0d87412a6739aba1f6de027a8e73 /io.c | |
parent | 84c11e85a4c4a12ecacba24afe9617222e4361e6 (diff) | |
download | android_external_rsync-f9185203ee03152001530db5624a2b8c93e1ea94.tar.gz android_external_rsync-f9185203ee03152001530db5624a2b8c93e1ea94.tar.bz2 android_external_rsync-f9185203ee03152001530db5624a2b8c93e1ea94.zip |
Added notifications about error-exit values:
- The receiver notifies the generator if it is exiting with an error,
and then, if it is a server, waits around for the generator to die.
This ensures that the client side has time to read the error.
- The generator or sender will notifiy the other side of the transfer of
an error-exit value if protocol 31 is in effect. This will get rid of
some "connection unexpectedly closed" errors that are really expected
events due to a fatal exit on the other side.
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -752,7 +752,7 @@ static char *perform_io(size_t needed, int flags) /* Don't write errors on a dead socket. */ msgs2stderr = 1; out->len = iobuf.raw_flushing_ends_before = out->pos = 0; - rsyserr(FERROR_SOCKET, errno, "write error"); + rsyserr(FERROR_SOCKET, errno, "[%s] write error", who_am_i()); exit_cleanup(RERR_STREAMIO); } } @@ -802,6 +802,16 @@ static char *perform_io(size_t needed, int flags) return data; } +void noop_io_until_death(void) +{ + char buf[1024]; + + kluge_around_eof = 1; + + while (1) + read_buf(iobuf.in_fd, buf, sizeof buf); +} + /* Buffer a message for the multiplexed output stream. Is never used for MSG_DATA. */ int send_msg(enum msgcode code, const char *buf, size_t len, int convert) { @@ -1426,6 +1436,16 @@ static void read_a_msg(void) first_message = 0; } break; + case MSG_ERROR_EXIT: + if (msg_bytes != 4) + goto invalid_msg; + data = perform_io(4, PIO_INPUT_AND_CONSUME); + val = IVAL(data, 0); + if (am_generator && protocol_version >= 31) + send_msg_int(MSG_ERROR_EXIT, val); + if (am_generator) + val = RERR_RCVR_ERROR; /* avoids duplicate errors */ + exit_cleanup(val); default: rprintf(FERROR, "unexpected tag %d [%s%s]\n", tag, who_am_i(), inc_recurse ? "/inc" : ""); |