From: Andrew Tridgell Date: Mon, 15 Nov 1999 01:32:20 +0000 (+0000) Subject: removed old non-blocking fd code (a hangover from a earlier version of X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/1f5c6343e6a3d55689073f60e71fd56cab42f89d removed old non-blocking fd code (a hangover from a earlier version of io.c). Thanks to Theo for pointing out this brokenness. --- diff --git a/clientserver.c b/clientserver.c index 84252432..5f03226d 100644 --- a/clientserver.c +++ b/clientserver.c @@ -433,8 +433,6 @@ int daemon_main(void) open("/dev/null", O_RDWR); } - set_nonblocking(STDIN_FILENO); - return start_daemon(STDIN_FILENO); } diff --git a/io.c b/io.c index 25d75168..9e2d3790 100644 --- a/io.c +++ b/io.c @@ -112,15 +112,6 @@ 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,"unexpected EOF in read_timeout\n"); @@ -333,7 +324,6 @@ static void writefd_unbuffered(int fd,char *buf,int len) int fd_count, count; struct timeval tv; int reading=0; - int blocked=0; no_flush++; @@ -371,25 +361,18 @@ static void writefd_unbuffered(int fd,char *buf,int len) } if (FD_ISSET(fd, &w_fds)) { - int n = (len-total)>>blocked; + int n = len-total; int ret = write(fd,buf+total,n?n:1); if (ret == -1 && errno == EINTR) { continue; } - if (ret == -1 && - (errno == EAGAIN || errno == EWOULDBLOCK)) { - blocked++; - continue; - } - if (ret <= 0) { rprintf(FERROR,"erroring writing %d bytes - exiting\n", len); exit_cleanup(RERR_STREAMIO); } - blocked = 0; total += ret; if (io_timeout) diff --git a/main.c b/main.c index 807409e3..bf52e652 100644 --- a/main.c +++ b/main.c @@ -261,10 +261,6 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[]) argv[0] = "."; } - set_nonblocking(f_out); - if (f_in != f_out) - set_nonblocking(f_in); - flist = send_file_list(f_out,argc,argv); if (!flist || flist->count == 0) { exit_cleanup(0); @@ -298,9 +294,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) close(recv_pipe[0]); if (f_in != f_out) close(f_out); - set_nonblocking(f_in); - set_nonblocking(recv_pipe[1]); - recv_files(f_in,flist,local_name,recv_pipe[1]); report(f_in); @@ -312,9 +305,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) io_close_input(f_in); if (f_in != f_out) close(f_in); - set_nonblocking(f_out); - set_nonblocking(recv_pipe[0]); - io_start_buffering(f_out); generate_files(f_out,flist,local_name,recv_pipe[0]); @@ -376,10 +366,6 @@ void start_server(int f_in, int f_out, int argc, char *argv[]) extern int cvs_exclude; extern int am_sender; - set_nonblocking(f_out); - if (f_in != f_out) - set_nonblocking(f_in); - setup_protocol(f_out, f_in); if (am_sender) { @@ -415,10 +401,6 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[]) if (verbose > 3) rprintf(FINFO,"file list sent\n"); - set_nonblocking(f_out); - if (f_in != f_out) - set_nonblocking(f_in); - send_files(flist,f_out,f_in); if (pid != -1) { if (verbose > 3) diff --git a/socket.c b/socket.c index 1e7a9edb..9c86c498 100644 --- a/socket.c +++ b/socket.c @@ -148,8 +148,6 @@ int open_socket_out(char *host, int port) return -1; } - set_nonblocking(res); - return res; } @@ -266,8 +264,6 @@ void start_accept_loop(int port, int (*fn)(int )) if (fork()==0) { close(s); - set_nonblocking(fd); - _exit(fn(fd)); } diff --git a/util.c b/util.c index 947caa7c..a0101657 100644 --- a/util.c +++ b/util.c @@ -26,33 +26,6 @@ extern int verbose; -/**************************************************************************** -Set a fd into nonblocking mode. Uses POSIX O_NONBLOCK if available, -else -if SYSV use O_NDELAY -if BSD use FNDELAY -****************************************************************************/ -int set_nonblocking(int fd) -{ - int val; -#ifdef O_NONBLOCK -#define FLAG_TO_SET O_NONBLOCK -#else -#ifdef SYSV -#define FLAG_TO_SET O_NDELAY -#else /* BSD */ -#define FLAG_TO_SET FNDELAY -#endif -#endif - - if((val = fcntl(fd, F_GETFL, 0)) == -1) - return -1; - val |= FLAG_TO_SET; - return fcntl( fd, F_SETFL, val); -#undef FLAG_TO_SET -} - - /* this is taken from CVS */ int piped_child(char **command,int *f_in,int *f_out) { @@ -101,9 +74,6 @@ int piped_child(char **command,int *f_in,int *f_out) *f_in = from_child_pipe[0]; *f_out = to_child_pipe[1]; - set_nonblocking(*f_in); - set_nonblocking(*f_out); - return pid; }