Fix bug #1211. Ensure accept socket is in non-blocking state in case of network
authorJeremy Allison <jra@samba.org>
Fri, 26 Mar 2004 23:02:53 +0000 (23:02 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 26 Mar 2004 23:02:53 +0000 (23:02 +0000)
error after select() returns true. (See accept man page on Linux). Patch from
rabies@meep.org (Richard Garnish).
Jeremy.

source/smbd/server.c

index 1de33739b24bd69c75d9a604890eb9bcd603f9b4..53d07fd905cc1669387cc694dab24188368c7956 100644 (file)
@@ -249,7 +249,10 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
                                /* ready to listen */
                                set_socket_options(s,"SO_KEEPALIVE"); 
                                set_socket_options(s,user_socket_options);
-      
+     
+                               /* Set server socket to non-blocking for the accept. */
+                               set_blocking(s,False); 
                                if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
                                        DEBUG(0,("listen: %s\n",strerror(errno)));
                                        close(s);
@@ -286,6 +289,9 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
                        set_socket_options(s,"SO_KEEPALIVE"); 
                        set_socket_options(s,user_socket_options);
                        
+                       /* Set server socket to non-blocking for the accept. */
+                       set_blocking(s,False); 
                        if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
                                DEBUG(0,("open_sockets_smbd: listen: %s\n",
                                         strerror(errno)));
@@ -378,6 +384,9 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
                                continue;
                        }
 
+                       /* Ensure child is set to blocking mode */
+                       set_blocking(smbd_server_fd(),True);
+
                        if (smbd_server_fd() != -1 && interactive)
                                return True;