handle non-blocking file descriptors for both read and write. Add a
authorAndrew Tridgell <tridge@samba.org>
Thu, 18 Jun 1998 09:33:46 +0000 (09:33 +0000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 18 Jun 1998 09:33:46 +0000 (09:33 +0000)
workaround for buggy systems that say there is space to write when
there isn't.

io.c

diff --git a/io.c b/io.c
index 61bdc60..7909e0b 100644 (file)
--- a/io.c
+++ b/io.c
@@ -108,6 +108,15 @@ static int read_timeout(int fd, char *buf, int len)
                        continue;
                }
 
+               if (n == -1 && 
+                   (errno == EAGAIN || errno == EWOULDBLOCK)) {
+                       /* this shouldn't happen, if it does then
+                          sleep for a short time to prevent us
+                          chewing too much CPU */
+                       u_sleep(100);
+                       continue;
+               }
+
                if (n == 0) {
                        if (eof_error) {
                                rprintf(FERROR,"EOF in read_timeout\n");
@@ -347,6 +356,15 @@ static void writefd_unbuffered(int fd,char *buf,int len)
                                continue;
                        }
 
+                       if (ret == -1 && 
+                           (errno == EAGAIN || errno == EWOULDBLOCK)) {
+                               /* this shouldn't happen, if it does then
+                                  sleep for a short time to prevent us
+                                  chewing too much CPU */
+                               u_sleep(100);
+                               continue;
+                       }
+
                        if (ret <= 0) {
                                rprintf(FERROR,"erroring writing %d bytes - exiting\n", len);
                                exit_cleanup(1);