dovecot-2.1: master: Increase process count limit (ulimit -u) at...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 9 18:23:33 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/eace12589314
changeset: 13690:eace12589314
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 09 18:33:59 2011 +0200
description:
master: Increase process count limit (ulimit -u) at startup high enough that we don't reach it.

diffstat:

 src/master/main.c |  22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diffs (34 lines):

diff -r 523f34bffc94 -r eace12589314 src/master/main.c
--- a/src/master/main.c	Wed Nov 09 18:30:27 2011 +0200
+++ b/src/master/main.c	Wed Nov 09 18:33:59 2011 +0200
@@ -428,8 +428,30 @@
 		i_info(STARTUP_STRING);
 }
 
+static void master_set_process_limit(void)
+{
+	struct service *const *servicep;
+	unsigned int process_limit = 0;
+	rlim_t nproc;
+
+	/* we'll just count all the processes that can exist and set the
+	   process limit so that we won't reach it. it's usually higher than
+	   needed, since we'd only need to set it high enough for each
+	   separate UID not to reach the limit, but this is difficult to
+	   guess: mail processes should probably be counted together for a
+	   common vmail user (unless system users are being used), but
+	   we can't really guess what the mail processes are. */
+	array_foreach(&services->services, servicep)
+		process_limit += (*servicep)->process_limit;
+
+	if (restrict_get_process_limit(&nproc) == 0 &&
+	    process_limit > nproc)
+		restrict_process_count(process_limit);
+}
+
 static void main_init(const struct master_settings *set)
 {
+	master_set_process_limit();
 	drop_capabilities();
 
 	/* deny file access from everyone else except owner */


More information about the dovecot-cvs mailing list