From 8d6aee954a62575e71f8c0d97429e09eaec4c132 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 26 Mar 2004 23:02:53 +0000 Subject: Fix bug #1211. Ensure accept socket is in non-blocking state in case of network error after select() returns true. (See accept man page on Linux). Patch from rabies@meep.org (Richard Garnish). Jeremy. (This used to be commit 6ca158291cf1f533ef18b542c84f22e9780c0966) --- source3/smbd/server.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/smbd') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 1de33739b2..53d07fd905 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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; -- cgit