- defer the error message from the options parsing until after the
[rsync/rsync.git] / io.c
diff --git a/io.c b/io.c
index 469eef3..fc62e45 100644 (file)
--- a/io.c
+++ b/io.c
@@ -119,7 +119,7 @@ static int read_timeout(int fd, char *buf, int len)
 
                if (n == 0) {
                        if (eof_error) {
-                               rprintf(FERROR,"EOF in read_timeout\n");
+                               rprintf(FERROR,"unexpected EOF in read_timeout\n");
                        }
                        exit_cleanup(1);
                }
@@ -238,7 +238,7 @@ static void readfd(int fd,char *buffer,int N)
        int  ret;
        int total=0;  
        
-       if (read_buffer_len < N && N < 1024) {
+       if ((read_buffer_len < N) && (N < 1024)) {
                read_check(buffer_f_in);
        }
        
@@ -323,14 +323,15 @@ static void writefd_unbuffered(int fd,char *buf,int len)
 
        no_flush++;
 
-       reading = (buffer_f_in != -1 && read_buffer_len < MAX_READ_BUFFER);
-
        while (total < len) {
                FD_ZERO(&w_fds);
                FD_ZERO(&r_fds);
                FD_SET(fd,&w_fds);
                fd_count = fd+1;
 
+               reading = (buffer_f_in != -1 && 
+                          read_buffer_len < MAX_READ_BUFFER);
+
                if (reading) {
                        FD_SET(buffer_f_in,&r_fds);
                        if (buffer_f_in > fd) 
@@ -350,6 +351,10 @@ static void writefd_unbuffered(int fd,char *buf,int len)
                        continue;
                }
 
+               if (reading && FD_ISSET(buffer_f_in, &r_fds)) {
+                       read_check(buffer_f_in);
+               }
+
                if (FD_ISSET(fd, &w_fds)) {
                        int n = (len-total)>>blocked;
                        int ret = write(fd,buf+total,n?n:1);
@@ -375,11 +380,6 @@ static void writefd_unbuffered(int fd,char *buf,int len)
 
                        if (io_timeout)
                                last_io = time(NULL);
-                       continue;
-               }
-
-               if (reading && FD_ISSET(buffer_f_in, &r_fds)) {
-                       read_check(buffer_f_in);
                }
        }