removed old non-blocking fd code (a hangover from a earlier version of
authorAndrew Tridgell <tridge@samba.org>
Mon, 15 Nov 1999 01:32:20 +0000 (01:32 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 15 Nov 1999 01:32:20 +0000 (01:32 +0000)
io.c). Thanks to Theo for pointing out this brokenness.

clientserver.c
io.c
main.c
socket.c
util.c

index 8425243..5f03226 100644 (file)
@@ -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 25d7516..9e2d379 100644 (file)
--- 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 807409e..bf52e65 100644 (file)
--- 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)
index 1e7a9ed..9c86c49 100644 (file)
--- 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 947caa7..a010165 100644 (file)
--- a/util.c
+++ b/util.c
 
 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;
 }