summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-26 23:02:53 +0000
committerJeremy Allison <jra@samba.org>2004-03-26 23:02:53 +0000
commit8d6aee954a62575e71f8c0d97429e09eaec4c132 (patch)
treedbb71223527c116b76d68d4848a6d1f215653cfc
parent87280e9a798895de827e5d1526fbac28a548f710 (diff)
downloadsamba-8d6aee954a62575e71f8c0d97429e09eaec4c132.tar.gz
samba-8d6aee954a62575e71f8c0d97429e09eaec4c132.tar.bz2
samba-8d6aee954a62575e71f8c0d97429e09eaec4c132.zip
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)
-rw-r--r--source3/smbd/server.c11
1 files changed, 10 insertions, 1 deletions
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;