svn commit: samba r10920 - in branches/SAMBA_4_0/source/smbd: .

tridge at samba.org tridge at samba.org
Wed Oct 12 11:04:02 GMT 2005


Author: tridge
Date: 2005-10-12 11:04:01 +0000 (Wed, 12 Oct 2005)
New Revision: 10920

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10920

Log:

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 

Modified:
   branches/SAMBA_4_0/source/smbd/process_single.c
   branches/SAMBA_4_0/source/smbd/process_standard.c
   branches/SAMBA_4_0/source/smbd/process_thread.c


Changeset:
Modified: branches/SAMBA_4_0/source/smbd/process_single.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/process_single.c	2005-10-12 08:53:42 UTC (rev 10919)
+++ branches/SAMBA_4_0/source/smbd/process_single.c	2005-10-12 11:04:01 UTC (rev 10920)
@@ -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 @@
 	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;
 	}
 

Modified: branches/SAMBA_4_0/source/smbd/process_standard.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/process_standard.c	2005-10-12 08:53:42 UTC (rev 10919)
+++ branches/SAMBA_4_0/source/smbd/process_standard.c	2005-10-12 11:04:01 UTC (rev 10920)
@@ -56,6 +56,9 @@
 	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;
 	}
 

Modified: branches/SAMBA_4_0/source/smbd/process_thread.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/process_thread.c	2005-10-12 08:53:42 UTC (rev 10919)
+++ branches/SAMBA_4_0/source/smbd/process_thread.c	2005-10-12 11:04:01 UTC (rev 10920)
@@ -89,6 +89,12 @@
 	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;
 	}
 



More information about the samba-cvs mailing list