dovecot-2.1: lib-master: Send service's idle_kill value to proce...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jan 20 18:28:45 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/3963862a4086
changeset: 13969:3963862a4086
user: Timo Sirainen <tss at iki.fi>
date: Fri Jan 20 18:27:44 2012 +0200
description:
lib-master: Send service's idle_kill value to process in environment.
diffstat:
src/lib-master/master-interface.h | 4 ++++
src/lib-master/master-service-private.h | 1 +
src/lib-master/master-service.c | 10 ++++++++++
src/lib-master/master-service.h | 4 ++++
src/master/service-process.c | 2 ++
5 files changed, 21 insertions(+), 0 deletions(-)
diffs (78 lines):
diff -r a6a53c658cab -r 3963862a4086 src/lib-master/master-interface.h
--- a/src/lib-master/master-interface.h Fri Jan 20 18:14:43 2012 +0200
+++ b/src/lib-master/master-interface.h Fri Jan 20 18:27:44 2012 +0200
@@ -52,6 +52,10 @@
process can finish handling before it should kill itself. */
#define MASTER_SERVICE_COUNT_ENV "SERVICE_COUNT"
+/* getenv(MASTER_SERVICE_IDLE_KILL_ENV) specifies service's idle_kill timeout
+ in seconds. */
+#define MASTER_SERVICE_IDLE_KILL_ENV "IDLE_KILL"
+
/* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file/socket */
#define MASTER_CONFIG_FILE_ENV "CONFIG_FILE"
diff -r a6a53c658cab -r 3963862a4086 src/lib-master/master-service-private.h
--- a/src/lib-master/master-service-private.h Fri Jan 20 18:14:43 2012 +0200
+++ b/src/lib-master/master-service-private.h Fri Jan 20 18:27:44 2012 +0200
@@ -37,6 +37,7 @@
unsigned int service_count_left;
unsigned int total_available_count;
unsigned int process_limit;
+ unsigned int idle_kill_secs;
struct master_status master_status;
unsigned int last_sent_status_avail_count;
diff -r a6a53c658cab -r 3963862a4086 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c Fri Jan 20 18:14:43 2012 +0200
+++ b/src/lib-master/master-service.c Fri Jan 20 18:27:44 2012 +0200
@@ -218,6 +218,11 @@
if (value != NULL && str_to_uint(value, &count) == 0 &&
count > 0)
master_service_set_service_count(service, count);
+
+ /* set the idle kill timeout */
+ value = getenv(MASTER_SERVICE_IDLE_KILL_ENV);
+ if (value != NULL && str_to_uint(value, &count) == 0)
+ service->idle_kill_secs = count;
} else {
master_service_set_client_limit(service, 1);
master_service_set_service_count(service, 1);
@@ -453,6 +458,11 @@
return service->process_limit;
}
+unsigned int master_service_get_idle_kill_secs(struct master_service *service)
+{
+ return service->idle_kill_secs;
+}
+
void master_service_set_service_count(struct master_service *service,
unsigned int count)
{
diff -r a6a53c658cab -r 3963862a4086 src/lib-master/master-service.h
--- a/src/lib-master/master-service.h Fri Jan 20 18:14:43 2012 +0200
+++ b/src/lib-master/master-service.h Fri Jan 20 18:27:44 2012 +0200
@@ -96,6 +96,10 @@
/* 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 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. */
+unsigned int master_service_get_idle_kill_secs(struct master_service *service);
/* Set maximum number of client connections we will handle before shutting
down. */
diff -r a6a53c658cab -r 3963862a4086 src/master/service-process.c
--- a/src/master/service-process.c Fri Jan 20 18:14:43 2012 +0200
+++ b/src/master/service-process.c Fri Jan 20 18:27:44 2012 +0200
@@ -227,6 +227,8 @@
service->client_limit));
env_put(t_strdup_printf(MASTER_PROCESS_LIMIT_ENV"=%u",
service->process_limit));
+ env_put(t_strdup_printf(MASTER_SERVICE_IDLE_KILL_ENV"=%u",
+ service->idle_kill));
if (service->set->service_count != 0) {
env_put(t_strdup_printf(MASTER_SERVICE_COUNT_ENV"=%u",
service->set->service_count));
More information about the dovecot-cvs
mailing list