Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6313:0e08960275f8 HEAD
Grow file descriptors to 64k at startup, and drop them for login and imap
processes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 24 Aug 2007 20:49:33 +0300 |
parents | 05aabdc581b1 |
children | c6d6ce742a82 |
files | dovecot-example.conf src/master/login-process.c src/master/mail-process.c src/master/main.c |
diffstat | 4 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Fri Aug 24 20:00:14 2007 +0300 +++ b/dovecot-example.conf Fri Aug 24 20:49:33 2007 +0300 @@ -164,8 +164,6 @@ # Maximum number of connections allowed per each login process. This setting # is used only if login_process_per_connection=no. Once the limit is reached, # the process notifies master so that it can create a new login process. -# You should make sure that the process has at least -# 16 + login_max_connections * 2 available file descriptors. #login_max_connections = 256 # Greeting message for clients.
--- a/src/master/login-process.c Fri Aug 24 20:00:14 2007 +0300 +++ b/src/master/login-process.c Fri Aug 24 20:49:33 2007 +0300 @@ -682,6 +682,10 @@ } restrict_process_size(group->set->login_process_size, (unsigned int)-1); + if (group->set->login_process_per_connection) + restrict_fd_limit(16 + 2); + else + restrict_fd_limit(16 + 2*group->set->login_max_connections); /* make sure we don't leak syslog fd, but do it last so that any errors above will be logged */
--- a/src/master/mail-process.c Fri Aug 24 20:00:14 2007 +0300 +++ b/src/master/mail-process.c Fri Aug 24 20:49:33 2007 +0300 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Timo Sirainen */ +/* Copyright (C) 2002 Timo Sirainen */ #include "common.h" #include "array.h" @@ -27,6 +27,8 @@ # include <sys/resource.h> #endif +/* 1024 should be more than enough */ +#define MAIL_PROCESS_FD_LIMIT 1024 /* Timeout chdir() completely after this many seconds */ #define CHDIR_TIMEOUT 30 /* Give a warning about chdir() taking a while if it took longer than this @@ -824,6 +826,7 @@ if (set->mail_drop_priv_before_exec) restrict_access_by_env(TRUE); + restrict_fd_limit(MAIL_PROCESS_FD_LIMIT); client_process_exec(set->mail_executable, title); i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m",
--- a/src/master/main.c Fri Aug 24 20:00:14 2007 +0300 +++ b/src/master/main.c Fri Aug 24 20:49:33 2007 +0300 @@ -8,6 +8,7 @@ #include "env-util.h" #include "fd-close-on-exec.h" #include "write-full.h" +#include "restrict-process-size.h" #include "askpass.h" #include "auth-process.h" @@ -27,6 +28,10 @@ #include <syslog.h> #include <sys/stat.h> +/* Try to raise our fd limit this high at startup. If the limit is already + higher, it's not dropped. */ +#define DOVECOT_MASTER_FD_MIN_LIMIT 65536 + static const char *configfile = SYSCONFDIR "/" PACKAGE ".conf"; struct ioloop *ioloop; @@ -172,6 +177,7 @@ static void main_init(bool log_error) { + (void)restrict_raise_fd_limit(DOVECOT_MASTER_FD_MIN_LIMIT); drop_capabilities(); /* deny file access from everyone else except owner */