Commit 07b7c86c authored by Andrew Tridgell's avatar Andrew Tridgell

don't write more than PIPE_BUF bytes in any one write() in io.c

this makes sure that the write never blocks.
parent 1f5c6343
...@@ -361,8 +361,11 @@ static void writefd_unbuffered(int fd,char *buf,int len) ...@@ -361,8 +361,11 @@ static void writefd_unbuffered(int fd,char *buf,int len)
} }
if (FD_ISSET(fd, &w_fds)) { if (FD_ISSET(fd, &w_fds)) {
int n = len-total; int ret, n = len-total;
int ret = write(fd,buf+total,n?n:1);
if (n > PIPE_BUF) n = PIPE_BUF;
ret = write(fd,buf+total,n?n:1);
if (ret == -1 && errno == EINTR) { if (ret == -1 && errno == EINTR) {
continue; continue;
......
...@@ -285,6 +285,10 @@ ...@@ -285,6 +285,10 @@
#define MAXPATHLEN 1024 #define MAXPATHLEN 1024
#endif #endif
#ifndef PIPE_BUF
#define PIPE_BUF 512
#endif
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff #define INADDR_NONE 0xffffffff
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment