X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/ef5d23ebcd67a59d2f89fbb5004c9ece4cc4d887..e92ee12893ca6320f5331384b2c2e8560ca9c88a:/io.c diff --git a/io.c b/io.c index 20fc2ba3..2f4162cd 100644 --- a/io.c +++ b/io.c @@ -39,16 +39,10 @@ extern int verbose; extern int io_timeout; extern struct stats stats; -static int buffer_f_in = -1; static int io_error_fd = -1; static void read_loop(int fd, char *buf, int len); -void setup_readbuffer(int f_in) -{ - buffer_f_in = f_in; -} - static void check_timeout(void) { extern int am_server, am_daemon; @@ -323,11 +317,7 @@ unsigned char read_byte(int f) return c; } - - -/* write len bytes to fd, possibly reading from buffer_f_in if set - in order to unclog the pipe. don't return until all len - bytes have been written */ +/* write len bytes to fd */ static void writefd_unbuffered(int fd,char *buf,int len) { int total = 0; @@ -382,6 +372,7 @@ static void writefd_unbuffered(int fd,char *buf,int len) if (ret == -1 && (errno == EWOULDBLOCK || errno == EAGAIN)) { + msleep(1); continue; } @@ -473,6 +464,17 @@ void io_end_buffering(int fd) } } +/* some OSes have a bug where an exit causes the pending writes on + a socket to be flushed. Do an explicit shutdown to try to prevent this */ +void io_shutdown(void) +{ + if (multiplex_out_fd != -1) close(multiplex_out_fd); + if (io_error_fd != -1) close(io_error_fd); + multiplex_out_fd = -1; + io_error_fd = -1; +} + + static void writefd(int fd,char *buf,int len) { stats.total_written += len; @@ -623,8 +625,3 @@ void io_multiplexing_close(void) io_multiplexing_out = 0; } -void io_close_input(int fd) -{ - buffer_f_in = -1; -} -