Mercurial > dovecot > core-2.2
changeset 9839:d76916a6df44 HEAD
Added service_count setting to limit how many requests a service can handle before dying.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 31 Aug 2009 14:07:35 -0400 |
parents | 777d8121356d |
children | 2dc1e03cad11 |
files | src/lib-master/master-interface.h src/lib-master/master-service.c src/master/master-settings.c src/master/master-settings.h src/master/service-process.c |
diffstat | 5 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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"
--- 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 @@ 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);
--- 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 @@ 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 @@ MEMBER(process_limit) (unsigned int)-1, MEMBER(client_limit) 0, + MEMBER(service_count) 0, MEMBER(vsz_limit) 256, MEMBER(unix_listeners) ARRAY_INIT,
--- 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 @@ unsigned int process_limit; unsigned int client_limit; + unsigned int service_count; unsigned int vsz_limit; ARRAY_TYPE(file_listener_settings) unix_listeners;
--- 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 @@ /* 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)