Commit 5dd7e031 authored by Andrew Tridgell's avatar Andrew Tridgell

put a limit (default 1MB) on the read buffer size. This stops it

growing too much if the sender is much faster than the receiver
parent 08ac228f
......@@ -75,6 +75,9 @@ static void read_check(int f)
/* things could deteriorate if we read in really small chunks */
if (n < 10) n = 1024;
if (n > MAX_READ_BUFFER/4)
n = MAX_READ_BUFFER/4;
if (read_buffer_p != read_buffer) {
memmove(read_buffer,read_buffer_p,read_buffer_len);
read_buffer_p = read_buffer;
......@@ -334,6 +337,7 @@ static int writefd_unbuffered(int fd,char *buf,int len)
if (ret == -1) {
if (read_buffer_len < MAX_READ_BUFFER)
read_check(buffer_f_in);
fd_count = fd+1;
......@@ -350,6 +354,7 @@ static int writefd_unbuffered(int fd,char *buf,int len)
tv.tv_usec = 0;
count = select(fd_count,buffer_f_in == -1? NULL: &r_fds,
&w_fds,NULL,&tv);
if (count == -1 && errno != EINTR) {
if (verbose > 1)
rprintf(FERROR,"select error: %s\n", strerror(errno));
......
......@@ -52,6 +52,7 @@
#define CHUNK_SIZE (32*1024)
#define MAX_MAP_SIZE (4*1024*1024)
#define IO_BUFFER_SIZE (4096)
#define MAX_READ_BUFFER (1024*1024)
#define MAX_ARGS 1000
......
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