From: Timo Sirainen Date: Wed, 9 Nov 2011 16:33:59 +0000 (+0200) Subject: master: Increase process count limit (ulimit -u) at startup high enough that we don... X-Git-Tag: 2.1.rc1~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a7f09949867080d0b2b4011f7605beff2585411;p=thirdparty%2Fdovecot%2Fcore.git master: Increase process count limit (ulimit -u) at startup high enough that we don't reach it. --- diff --git a/src/master/main.c b/src/master/main.c index 63c061d466..d149be200c 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -428,8 +428,30 @@ static void main_log_startup(void) 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 */