dovecot-2.0: Added service_count setting to limit how many reque...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 31 21:14:37 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/d76916a6df44
changeset: 9839:d76916a6df44
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 31 14:07:35 2009 -0400
description:
Added service_count setting to limit how many requests a service can handle before dying.

diffstat:

5 files changed, 18 insertions(+), 1 deletion(-)
src/lib-master/master-interface.h |    4 ++++
src/lib-master/master-service.c   |    7 +++++++
src/master/master-settings.c      |    2 ++
src/master/master-settings.h      |    1 +
src/master/service-process.c      |    5 ++++-

diffs (77 lines):

diff -r 777d8121356d -r d76916a6df44 src/lib-master/master-interface.h
--- a/src/lib-master/master-interface.h	Mon Aug 31 14:06:50 2009 -0400
+++ b/src/lib-master/master-interface.h	Mon Aug 31 14:07:35 2009 -0400
@@ -77,6 +77,10 @@ struct master_auth_reply {
    master_status.available_count as specified in configuration file */
 #define MASTER_CLIENT_LIMIT_ENV "CLIENT_LIMIT"
 
+/* getenv(MASTER_SERVICE_COUNT_ENV) specifies how many client connections the
+   process can finish handling before it should kill itself. */
+#define MASTER_SERVICE_COUNT_ENV "SERVICE_COUNT"
+
 /* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file/socket */
 #define MASTER_CONFIG_FILE_ENV "CONFIG_FILE"
 
diff -r 777d8121356d -r d76916a6df44 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Mon Aug 31 14:06:50 2009 -0400
+++ b/src/lib-master/master-service.c	Mon Aug 31 14:07:35 2009 -0400
@@ -273,6 +273,13 @@ void master_service_init_finish(struct m
 			i_fatal(MASTER_CLIENT_LIMIT_ENV" not set");
 		master_service_set_client_limit(service, count);
 
+		/* set the default service count */
+		value = getenv(MASTER_SERVICE_COUNT_ENV);
+		count = value == NULL ? 0 :
+			(unsigned int)strtoul(value, NULL, 10);
+		if (count > 0)
+			master_service_set_service_count(service, count);
+
 		/* start listening errors for status fd, it means master died */
 		service->io_status_error = io_add(MASTER_STATUS_FD, IO_ERROR,
 						  master_status_error, service);
diff -r 777d8121356d -r d76916a6df44 src/master/master-settings.c
--- a/src/master/master-settings.c	Mon Aug 31 14:06:50 2009 -0400
+++ b/src/master/master-settings.c	Mon Aug 31 14:07:35 2009 -0400
@@ -102,6 +102,7 @@ static struct setting_define service_set
 
 	DEF(SET_UINT, process_limit),
 	DEF(SET_UINT, client_limit),
+	DEF(SET_UINT, service_count),
 	DEF(SET_UINT, vsz_limit),
 
 	DEFLIST(unix_listeners, "unix_listener",
@@ -132,6 +133,7 @@ static struct service_settings service_d
 
 	MEMBER(process_limit) (unsigned int)-1,
 	MEMBER(client_limit) 0,
+	MEMBER(service_count) 0,
 	MEMBER(vsz_limit) 256,
 
 	MEMBER(unix_listeners) ARRAY_INIT,
diff -r 777d8121356d -r d76916a6df44 src/master/master-settings.h
--- a/src/master/master-settings.h	Mon Aug 31 14:06:50 2009 -0400
+++ b/src/master/master-settings.h	Mon Aug 31 14:07:35 2009 -0400
@@ -33,6 +33,7 @@ struct service_settings {
 
 	unsigned int process_limit;
 	unsigned int client_limit;
+	unsigned int service_count;
 	unsigned int vsz_limit;
 
 	ARRAY_TYPE(file_listener_settings) unix_listeners;
diff -r 777d8121356d -r d76916a6df44 src/master/service-process.c
--- a/src/master/service-process.c	Mon Aug 31 14:06:50 2009 -0400
+++ b/src/master/service-process.c	Mon Aug 31 14:07:35 2009 -0400
@@ -401,8 +401,11 @@ service_process_setup_environment(struct
 		/* fallback to default limit */
 		limit = service->set->master_set->default_client_limit;
 	}
-
 	env_put(t_strdup_printf(MASTER_CLIENT_LIMIT_ENV"=%u", limit));
+	if (service->set->service_count != 0) {
+		env_put(t_strdup_printf(MASTER_SERVICE_COUNT_ENV"=%u",
+					service->set->service_count));
+	}
 	env_put(t_strdup_printf(MASTER_UID_ENV"=%u", uid));
 
 	if (!service->set->master_set->version_ignore)


More information about the dovecot-cvs mailing list