fix realloc call for systems that don't handle realloc(NULL, ...)
[rsync/rsync.git] / io.c
diff --git a/io.c b/io.c
index 4c704eb..e9a66a4 100644 (file)
--- a/io.c
+++ b/io.c
@@ -32,10 +32,11 @@ static int io_multiplexing_in;
 static int multiplex_in_fd;
 static int multiplex_out_fd;
 static time_t last_io;
-
+static int eof_error=1;
 extern int verbose;
 extern int io_timeout;
 
+
 int64 write_total(void)
 {
        return total_written;
@@ -86,6 +87,8 @@ static int read_timeout(int fd, char *buf, int len)
 {
        int n, ret=0;
 
+       io_flush();
+
        while (ret == 0) {
                fd_set fds;
                struct timeval tv;
@@ -117,7 +120,9 @@ static int read_timeout(int fd, char *buf, int len)
                }
 
                if (n == 0) {
-                       rprintf(FERROR,"EOF in read_timeout\n");
+                       if (eof_error) {
+                               rprintf(FERROR,"EOF in read_timeout\n");
+                       }
                        exit_cleanup(1);
                }
 
@@ -480,8 +485,12 @@ void write_byte(int f,unsigned char c)
 
 int read_line(int f, char *buf, int maxlen)
 {
+       eof_error = 0;
+
        while (maxlen) {
+               buf[0] = 0;
                read_buf(f, buf, 1);
+               if (buf[0] == 0) return 0;
                if (buf[0] == '\n') {
                        buf[0] = 0;
                        break;
@@ -495,6 +504,9 @@ int read_line(int f, char *buf, int maxlen)
                *buf = 0;
                return 0;
        }
+
+       eof_error = 1;
+
        return 1;
 }