From: Paul Mackerras Date: Fri, 28 Jun 1996 07:06:34 +0000 (+0000) Subject: standard input on server may be nonblocking X-Git-Tag: v1.6.4~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f28dbee65cef6e1990552c3eb3eb450ef9e98f2;p=thirdparty%2Frsync.git standard input on server may be nonblocking --- diff --git a/io.c b/io.c index b7d27e62..38868751 100644 --- a/io.c +++ b/io.c @@ -103,8 +103,15 @@ static int readfd(int fd,char *buffer,int N) read_buffer_p += ret; read_buffer_len -= ret; } else { - if ((ret = read(fd,buffer + total,N - total)) == -1) - return -1; + while ((ret = read(fd,buffer + total,N - total)) == -1) { + fd_set fds; + + if (errno != EAGAIN && errno != EWOULDBLOCK) + return -1; + FD_ZERO(&fds); + FD_SET(fd, &fds); + select(fd+1, &fds, NULL, NULL, NULL); + } } if (ret <= 0) @@ -194,7 +201,7 @@ static int writefd(int fd,char *buf,int len) FD_SET(fd,&fds); tv.tv_sec = BLOCKING_TIMEOUT; tv.tv_usec = 0; - select(16,NULL,&fds,NULL,&tv); + select(fd+1,NULL,&fds,NULL,&tv); } else { total += ret; }