X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/a0f1ed55cd5ae7393b904b2e2bd31c2ee0b59d40..f9185203ee03152001530db5624a2b8c93e1ea94:/io.c diff --git a/io.c b/io.c index a85bcfaf..1e2f2187 100644 --- a/io.c +++ b/io.c @@ -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) { @@ -1307,7 +1317,7 @@ static void read_a_msg(void) send_msg(MSG_IO_ERROR, data, 4, 0); break; case MSG_IO_TIMEOUT: - if (msg_bytes != 4 || am_sender || am_generator) + if (msg_bytes != 4 || am_server || am_generator) goto invalid_msg; data = perform_io(4, PIO_INPUT_AND_CONSUME); val = IVAL(data, 0); @@ -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" : "");