*/
#include "rsync.h"
+/* if no timeout is specified then use a 60 second select timeout */
+#define SELECT_TIMEOUT 60
+
static int io_multiplexing_out;
static int io_multiplexing_in;
static int multiplex_in_fd;
static int read_buffer_len;
static int read_buffer_size;
static int no_flush;
+static int no_flush_read;
/* read from a socket with IO timeout. return the number of
bytes read. If no bytes can be read then exit, never return
{
int n, ret=0;
+ no_flush_read++;
io_flush();
+ no_flush_read--;
while (ret == 0) {
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
- tv.tv_sec = io_timeout;
+ tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT;
tv.tv_usec = 0;
- if (select(fd+1, &fds, NULL, NULL,
- io_timeout?&tv:NULL) != 1) {
+ if (select(fd+1, &fds, NULL, NULL, &tv) != 1) {
check_timeout();
continue;
}
continue;
}
+ no_flush_read++;
io_flush();
+ no_flush_read--;
ret = read_unbuffered(fd,buffer + total,N-total);
total += ret;
fd_set w_fds, r_fds;
int fd_count, count;
struct timeval tv;
- int reading;
+ int reading=0;
int blocked=0;
no_flush++;
FD_SET(fd,&w_fds);
fd_count = fd+1;
- reading = (buffer_f_in != -1 &&
- read_buffer_len < MAX_READ_BUFFER);
+ if (!no_flush_read) {
+ reading = (buffer_f_in != -1);
+ }
if (reading) {
FD_SET(buffer_f_in,&r_fds);
fd_count = buffer_f_in+1;
}
- tv.tv_sec = io_timeout;
+ tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT;
tv.tv_usec = 0;
count = select(fd_count,
reading?&r_fds:NULL,
&w_fds,NULL,
- io_timeout?&tv:NULL);
+ &tv);
if (count <= 0) {
check_timeout();
}
/* write a string to the connection */
-void write_sbuf(int f,char *buf)
+static void write_sbuf(int f,char *buf)
{
write_buf(f, buf, strlen(buf));
}