summaryrefslogtreecommitdiffstats
path: root/source/smbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-12 11:04:01 +0000
committerAndrew Tridgell <tridge@samba.org>2005-10-12 11:04:01 +0000
commit4e56c9c524afe3626f8fdb042a7381694707bedb (patch)
treea567c3146ffd89ed44c7704e47f154798cd12c53 /source/smbd
parent0e4128fa76fb53943391df933709262f9da4d494 (diff)
downloadsamba-4e56c9c524afe3626f8fdb042a7381694707bedb.tar.gz
samba-4e56c9c524afe3626f8fdb042a7381694707bedb.tar.xz
samba-4e56c9c524afe3626f8fdb042a7381694707bedb.zip
r10920: in case of a accept() failure just failing and trying again is no
good, as it is probably a resource constraint, so if we just try again we will spin (as the incoming socket will still be readable). Using a sleep(1) solves this by throtting smbd until the resource constraint goes away. if the resource constraint doesn't go away, then at least smbd won't be spinning chewing cpu
Diffstat (limited to 'source/smbd')
-rw-r--r--source/smbd/process_single.c8
-rw-r--r--source/smbd/process_standard.c3
-rw-r--r--source/smbd/process_thread.c6
3 files changed, 17 insertions, 0 deletions
diff --git a/source/smbd/process_single.c b/source/smbd/process_single.c
index 56b074a6294..8c9dd2f7fa7 100644
--- a/source/smbd/process_single.c
+++ b/source/smbd/process_single.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "dlinklist.h"
#include "smb_server/smb_server.h"
+#include "system/filesys.h"
/*
@@ -51,6 +52,13 @@ static void single_accept_connection(struct event_context *ev,
status = socket_accept(sock, &sock2);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("accept_connection_single: accept: %s\n", nt_errstr(status)));
+ /* this looks strange, but is correct. We need to
+ throttle things until the system clears enough
+ resources to handle this new socket. If we don't
+ then we will spin filling the log and causing more
+ problems. We don't panic as this is probably a
+ temporary resource constraint */
+ sleep(1);
return;
}
diff --git a/source/smbd/process_standard.c b/source/smbd/process_standard.c
index 014bd34afd6..bbc0aa4c7ed 100644
--- a/source/smbd/process_standard.c
+++ b/source/smbd/process_standard.c
@@ -56,6 +56,9 @@ static void standard_accept_connection(struct event_context *ev,
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("standard_accept_connection: accept: %s\n",
nt_errstr(status)));
+ /* this looks strange, but is correct. We need to throttle things until
+ the system clears enough resources to handle this new socket */
+ sleep(1);
return;
}
diff --git a/source/smbd/process_thread.c b/source/smbd/process_thread.c
index 692cd067240..e5ed74e9397 100644
--- a/source/smbd/process_thread.c
+++ b/source/smbd/process_thread.c
@@ -89,6 +89,12 @@ static void thread_accept_connection(struct event_context *ev,
status = socket_accept(sock, &state->sock);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(ev2);
+ /* We need to throttle things until the system clears
+ enough resources to handle this new socket. If we
+ don't then we will spin filling the log and causing
+ more problems. We don't panic as this is probably a
+ temporary resource constraint */
+ sleep(1);
return;
}