dovecot-2.0: Added support for per-service idle kill timeout.

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 25 16:03:54 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/d41694c931d0
changeset: 11631:d41694c931d0
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 25 14:03:20 2010 +0100
description:
Added support for per-service idle kill timeout.
Director and anvil services are by default never killed.
This also fixes the errors about idling director process not dying.

diffstat:

 src/anvil/anvil-settings.c           |  1 +
 src/auth/auth-settings.c             |  2 ++
 src/config/config-settings.c         |  1 +
 src/dict/dict-settings.c             |  1 +
 src/director/director-settings.c     |  1 +
 src/dns/dns-client-settings.c        |  1 +
 src/imap-login/imap-login-settings.c |  1 +
 src/imap/imap-settings.c             |  1 +
 src/lib-master/service-settings.h    |  1 +
 src/lmtp/lmtp-settings.c             |  1 +
 src/log/log-settings.c               |  1 +
 src/master/master-settings.c         |  4 ++++
 src/master/master-settings.h         |  1 +
 src/master/service-monitor.c         |  5 ++---
 src/master/service.c                 |  2 ++
 src/master/service.h                 |  2 ++
 src/pop3-login/pop3-login-settings.c |  1 +
 src/pop3/pop3-settings.c             |  1 +
 src/ssl-params/ssl-params-settings.c |  1 +
 src/util/tcpwrap-settings.c          |  1 +
 20 files changed, 27 insertions(+), 3 deletions(-)

diffs (269 lines):

diff -r c9a62b0d9d36 -r d41694c931d0 src/anvil/anvil-settings.c
--- a/src/anvil/anvil-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/anvil/anvil-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -38,6 +38,7 @@
 	.process_limit = 1,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = -1U,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &anvil_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/auth/auth-settings.c
--- a/src/auth/auth-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/auth/auth-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -51,6 +51,7 @@
 	.process_limit = 1,
 	.client_limit = 4096,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &auth_unix_listeners_buf,
@@ -88,6 +89,7 @@
 	.process_limit = 0,
 	.client_limit = 1,
 	.service_count = 1,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &auth_worker_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/config/config-settings.c
--- a/src/config/config-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/config/config-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -36,6 +36,7 @@
 	.process_limit = 0,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &config_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/dict/dict-settings.c
--- a/src/dict/dict-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/dict/dict-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -35,6 +35,7 @@
 	.process_limit = 0,
 	.client_limit = 1,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &dict_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/director/director-settings.c
--- a/src/director/director-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/director/director-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -48,6 +48,7 @@
 	.process_limit = 1,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = -1U,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &director_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/dns/dns-client-settings.c
--- a/src/dns/dns-client-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/dns/dns-client-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -38,6 +38,7 @@
 	.process_limit = 0,
 	.client_limit = 1,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &dns_client_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/imap-login/imap-login-settings.c
--- a/src/imap-login/imap-login-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/imap-login/imap-login-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -40,6 +40,7 @@
 	.process_limit = 0,
 	.client_limit = 0,
 	.service_count = 1,
+	.idle_kill = 0,
 	.vsz_limit = 64,
 
 	.unix_listeners = ARRAY_INIT,
diff -r c9a62b0d9d36 -r d41694c931d0 src/imap/imap-settings.c
--- a/src/imap/imap-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/imap/imap-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -43,6 +43,7 @@
 	.process_limit = 1024,
 	.client_limit = 1,
 	.service_count = 1,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &imap_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/lib-master/service-settings.h
--- a/src/lib-master/service-settings.h	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/lib-master/service-settings.h	Fri Jun 25 14:03:20 2010 +0100
@@ -44,6 +44,7 @@
 	unsigned int process_limit;
 	unsigned int client_limit;
 	unsigned int service_count;
+	unsigned int idle_kill;
 	uoff_t vsz_limit;
 
 	ARRAY_TYPE(file_listener_settings) unix_listeners;
diff -r c9a62b0d9d36 -r d41694c931d0 src/lmtp/lmtp-settings.c
--- a/src/lmtp/lmtp-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/lmtp/lmtp-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -41,6 +41,7 @@
 	.process_limit = 0,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = 0,
 
 	.unix_listeners = { { &lmtp_login_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/log/log-settings.c
--- a/src/log/log-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/log/log-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -23,6 +23,7 @@
 	.process_limit = 1,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = ARRAY_INIT,
diff -r c9a62b0d9d36 -r d41694c931d0 src/master/master-settings.c
--- a/src/master/master-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/master/master-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -111,6 +111,7 @@
 	DEF(SET_UINT, process_limit),
 	DEF(SET_UINT, client_limit),
 	DEF(SET_UINT, service_count),
+	DEF(SET_TIME, idle_kill),
 	DEF(SET_SIZE, vsz_limit),
 
 	DEFLIST_UNIQUE(unix_listeners, "unix_listener",
@@ -140,6 +141,7 @@
 	.process_limit = -1U,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = (uoff_t)-1,
 
 	.unix_listeners = ARRAY_INIT,
@@ -175,6 +177,7 @@
 	DEF(SET_STR, default_login_user),
 	DEF(SET_UINT, default_process_limit),
 	DEF(SET_UINT, default_client_limit),
+	DEF(SET_UINT, default_idle_kill),
 	DEF(SET_SIZE, default_vsz_limit),
 
 	DEF(SET_BOOL, version_ignore),
@@ -201,6 +204,7 @@
 	.default_login_user = "dovenull",
 	.default_process_limit = 100,
 	.default_client_limit = 1000,
+	.default_idle_kill = 60,
 	.default_vsz_limit = 256*1024*1024,
 
 	.version_ignore = FALSE,
diff -r c9a62b0d9d36 -r d41694c931d0 src/master/master-settings.h
--- a/src/master/master-settings.h	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/master/master-settings.h	Fri Jun 25 14:03:20 2010 +0100
@@ -13,6 +13,7 @@
 	const char *default_login_user;
 	unsigned int default_process_limit;
 	unsigned int default_client_limit;
+	unsigned int default_idle_kill;
 	uoff_t default_vsz_limit;
 
 	bool version_ignore;
diff -r c9a62b0d9d36 -r d41694c931d0 src/master/service-monitor.c
--- a/src/master/service-monitor.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/master/service-monitor.c	Fri Jun 25 14:03:20 2010 +0100
@@ -20,7 +20,6 @@
 #include <syslog.h>
 #include <signal.h>
 
-#define SERVICE_PROCESS_KILL_IDLE_MSECS (1000*60)
 #define SERVICE_STARTUP_FAILURE_THROTTLE_SECS 60
 #define SERVICE_DROP_WARN_INTERVAL_SECS 60
 
@@ -99,12 +98,12 @@
 		process->idle_start = ioloop_time;
 		if (service->process_avail > service->set->process_min_avail &&
 		    process->to_idle == NULL &&
-		    service->type != SERVICE_TYPE_ANVIL) {
+		    service->idle_kill != -1U) {
 			/* we have more processes than we really need.
 			   add a bit of randomness so that we don't send the
 			   signal to all of them at once */
 			process->to_idle =
-				timeout_add(SERVICE_PROCESS_KILL_IDLE_MSECS +
+				timeout_add((service->set->idle_kill * 1000) +
 					    (rand() % 100)*10,
 					    service_process_kill_idle,
 					    process);
diff -r c9a62b0d9d36 -r d41694c931d0 src/master/service.c
--- a/src/master/service.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/master/service.c	Fri Jun 25 14:03:20 2010 +0100
@@ -194,6 +194,8 @@
 
 	service->vsz_limit = set->vsz_limit != (uoff_t)-1 ? set->vsz_limit :
 		set->master_set->default_vsz_limit;
+	service->idle_kill = set->idle_kill != 0 ? set->idle_kill :
+		set->master_set->default_idle_kill;
 	service->type = service->set->parsed_type;
 
 	if (set->process_limit == 0) {
diff -r c9a62b0d9d36 -r d41694c931d0 src/master/service.h
--- a/src/master/service.h	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/master/service.h	Fri Jun 25 14:03:20 2010 +0100
@@ -64,6 +64,8 @@
 
 	/* Maximum number of client connections a process can handle. */
 	unsigned int client_limit;
+	/* Kill idling processes after this many seconds. */
+	unsigned int idle_kill;
 	/* set->vsz_limit or set->master_set->default_client_limit */
 	uoff_t vsz_limit;
 
diff -r c9a62b0d9d36 -r d41694c931d0 src/pop3-login/pop3-login-settings.c
--- a/src/pop3-login/pop3-login-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/pop3-login/pop3-login-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -40,6 +40,7 @@
 	.process_limit = 0,
 	.client_limit = 0,
 	.service_count = 1,
+	.idle_kill = 0,
 	.vsz_limit = 64,
 
 	.unix_listeners = ARRAY_INIT,
diff -r c9a62b0d9d36 -r d41694c931d0 src/pop3/pop3-settings.c
--- a/src/pop3/pop3-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/pop3/pop3-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -43,6 +43,7 @@
 	.process_limit = 1024,
 	.client_limit = 1,
 	.service_count = 1,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &pop3_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/ssl-params/ssl-params-settings.c
--- a/src/ssl-params/ssl-params-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/ssl-params/ssl-params-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -40,6 +40,7 @@
 	.process_limit = 0,
 	.client_limit = 0,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = { { &ssl_params_unix_listeners_buf,
diff -r c9a62b0d9d36 -r d41694c931d0 src/util/tcpwrap-settings.c
--- a/src/util/tcpwrap-settings.c	Thu Jun 24 22:32:05 2010 +0100
+++ b/src/util/tcpwrap-settings.c	Fri Jun 25 14:03:20 2010 +0100
@@ -25,6 +25,7 @@
 	.process_limit = 0,
 	.client_limit = 1,
 	.service_count = 0,
+	.idle_kill = 0,
 	.vsz_limit = -1U,
 
 	.unix_listeners = ARRAY_INIT,


More information about the dovecot-cvs mailing list