From f7b9377863c25088412a704cc0834460d0d6c86b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Jun 1998 09:33:46 +0000 Subject: [PATCH] handle non-blocking file descriptors for both read and write. Add a workaround for buggy systems that say there is space to write when there isn't. --- io.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/io.c b/io.c index 61bdc609..7909e0b1 100644 --- 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); -- 2.34.1