[PATCH] s3: runtime maximum winbindd simultaneous clients

Pierre Carrier pcarrier at redhat.com
Mon Sep 13 07:57:23 MDT 2010


Allows changing the maximum number of simultaneous clients in winbindd through the -m|--max-clients option.
---
 source3/include/local.h     |    2 +-
 source3/winbindd/winbindd.c |   20 +++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/source3/include/local.h b/source3/include/local.h
index a3baf64..53f489f 100644
--- a/source3/include/local.h
+++ b/source3/include/local.h
@@ -240,7 +240,7 @@
 #define WINBIND_SERVER_MUTEX_WAIT_TIME (( ((NUM_CLI_AUTH_CONNECT_RETRIES) * ((CLI_AUTH_TIMEOUT)/1000)) + 5)*2)
 
 /* Max number of simultaneous winbindd socket connections. */
-#define WINBINDD_MAX_SIMULTANEOUS_CLIENTS 200
+#define WINBINDD_DEFAULT_MAX_SIMULTANEOUS_CLIENTS 200
 
 /* Buffer size to use when printing backtraces */
 #define BACKTRACE_STACK_SIZE 64
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 7a9ebb8..16a9fad 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -42,6 +42,8 @@ static void remove_client(struct winbindd_cli_state *state);
 static bool opt_nocache = False;
 static bool interactive = False;
 
+static int max_clients = WINBINDD_DEFAULT_MAX_SIMULTANEOUS_CLIENTS;
+
 extern bool override_logfile;
 
 /* Reload configuration */
@@ -908,17 +910,14 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
 	struct winbindd_listen_state *s = talloc_get_type_abort(private_data,
 					  struct winbindd_listen_state);
 
-	while (winbindd_num_clients() >
-	       WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) {
+	while (winbindd_num_clients() > max_clients - 1) {
 		DEBUG(5,("winbindd: Exceeding %d client "
 			 "connections, removing idle "
-			 "connection.\n",
-			 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
+			 "connection.\n", max_clients));
 		if (!remove_idle_client()) {
 			DEBUG(0,("winbindd: Exceeding %d "
 				 "client connections, no idle "
-				 "connection found\n",
-				 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
+				 "connection found\n", max_clients));
 			break;
 		}
 	}
@@ -1107,7 +1106,8 @@ int main(int argc, char **argv, char **envp)
 		OPT_DAEMON = 1000,
 		OPT_FORK,
 		OPT_NO_PROCESS_GROUP,
-		OPT_LOG_STDOUT
+		OPT_LOG_STDOUT,
+		OPT_MAX_CLIENTS
 	};
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -1115,6 +1115,8 @@ int main(int argc, char **argv, char **envp)
 		{ "foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Daemon in foreground mode" },
 		{ "no-process-group", 0, POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" },
 		{ "daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon (default)" },
+		{ "max-clients", 'm', POPT_ARG_INT, &max_clients, OPT_MAX_CLIENTS, "Maximum simultaneous clients ("
+			__STRING(WINBINDD_DEFAULT_MAX_SIMULTANEOUS_CLIENTS) "by default)" },
 		{ "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
 		{ "no-caching", 'n', POPT_ARG_NONE, NULL, 'n', "Disable caching" },
 		POPT_COMMON_SAMBA
@@ -1215,6 +1217,10 @@ int main(int argc, char **argv, char **envp)
 	DEBUG(0,("winbindd version %s started.\n", samba_version_string()));
 	DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
+	if(max_clients != WINBINDD_DEFAULT_MAX_SIMULTANEOUS_CLIENTS) {
+		DEBUG(0,("Maximum number of simultaneous clients set to %i.\n", max_clients));
+	}
+
 	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
 		DEBUG(0, ("error opening config file\n"));
 		exit(1);
-- 
1.7.2.3



More information about the samba-technical mailing list