From: Timo Sirainen Date: Thu, 4 Apr 2013 20:35:08 +0000 (+0300) Subject: lib-master: Added master_service_get_process_min_avail() X-Git-Tag: 2.2.rc4~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4845c4245638fd6f02dc0cb92c3465fae763cbb;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Added master_service_get_process_min_avail() --- diff --git a/src/lib-master/master-interface.h b/src/lib-master/master-interface.h index 3ffa04b0a9..5b1f01222e 100644 --- a/src/lib-master/master-interface.h +++ b/src/lib-master/master-interface.h @@ -48,6 +48,10 @@ enum master_login_state { can be created before reaching the limit */ #define MASTER_PROCESS_LIMIT_ENV "PROCESS_LIMIT" +/* getenv(MASTER_PROCESS_MIN_AVAIL_ENV) specifies how many processes of this + type are created at startup and are kept running all the time */ +#define MASTER_PROCESS_MIN_AVAIL_ENV "PROCESS_MIN_AVAIL" + /* 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" diff --git a/src/lib-master/master-service-private.h b/src/lib-master/master-service-private.h index b01cef38aa..ccba6a6b1a 100644 --- a/src/lib-master/master-service-private.h +++ b/src/lib-master/master-service-private.h @@ -37,6 +37,7 @@ struct master_service { unsigned int service_count_left; unsigned int total_available_count; unsigned int process_limit; + unsigned int process_min_avail; unsigned int idle_kill_secs; struct master_status master_status; diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index f762248a87..378bc6343d 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -216,6 +216,11 @@ master_service_init(const char *name, enum master_service_flags flags, count > 0) service->process_limit = count; + value = getenv(MASTER_PROCESS_MIN_AVAIL_ENV); + if (value != NULL && str_to_uint(value, &count) == 0 && + count > 0) + service->process_min_avail = count; + /* set the default service count */ value = getenv(MASTER_SERVICE_COUNT_ENV); if (value != NULL && str_to_uint(value, &count) == 0 && @@ -491,6 +496,11 @@ unsigned int master_service_get_process_limit(struct master_service *service) return service->process_limit; } +unsigned int master_service_get_process_min_avail(struct master_service *service) +{ + return service->process_min_avail; +} + unsigned int master_service_get_idle_kill_secs(struct master_service *service) { return service->idle_kill_secs; diff --git a/src/lib-master/master-service.h b/src/lib-master/master-service.h index e1896dba45..b975895101 100644 --- a/src/lib-master/master-service.h +++ b/src/lib-master/master-service.h @@ -105,6 +105,8 @@ unsigned int master_service_get_client_limit(struct master_service *service); /* Returns how many processes of this type can be created before reaching the limit. */ unsigned int master_service_get_process_limit(struct master_service *service); +/* Returns service { process_min_avail } */ +unsigned int master_service_get_process_min_avail(struct master_service *service); /* Returns the service's idle_kill timeout in seconds. Normally master handles sending the kill request when the process has no clients, but some services with permanent client connections may need to handle this themselves. */ diff --git a/src/master/service-process.c b/src/master/service-process.c index f6d1f4031c..c0568e58ab 100644 --- a/src/master/service-process.c +++ b/src/master/service-process.c @@ -228,6 +228,8 @@ service_process_setup_environment(struct service *service, unsigned int uid) service->client_limit)); env_put(t_strdup_printf(MASTER_PROCESS_LIMIT_ENV"=%u", service->process_limit)); + env_put(t_strdup_printf(MASTER_PROCESS_MIN_AVAIL_ENV"=%u", + service->set->process_min_avail)); env_put(t_strdup_printf(MASTER_SERVICE_IDLE_KILL_ENV"=%u", service->idle_kill)); if (service->set->service_count != 0) {