Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6398:e41718b974d2 HEAD
Calculate how many log fds login+mail processes can use. If it's lower than
the current fd limit, log a warning.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 15 Sep 2007 16:59:08 +0300 |
parents | 08eaa53f1aaa |
children | 91db6ee4de5e |
files | src/master/master-settings.c |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/master/master-settings.c Sat Sep 15 16:58:36 2007 +0300 +++ b/src/master/master-settings.c Sat Sep 15 16:59:08 2007 +0300 @@ -1381,6 +1381,36 @@ return FALSE; } +static void +settings_warn_needed_fds(struct server_settings *server __attr_unused__) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit rlim; + unsigned int fd_count = 0; + + if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) + return; + + /* count only log pipes needed for login and mail processes. we need + more, but they're the ones that can use up most of the fds */ + for (; server != NULL; server = server->next) { + if (settings_is_active(server->imap)) + fd_count += server->imap->login_max_processes_count; + if (settings_is_active(server->pop3)) + fd_count += server->pop3->login_max_processes_count; + fd_count += server->defaults->max_mail_processes; + } + + if (rlim.rlim_cur < fd_count) { + i_warning("fd limit %d is lower than what Dovecot can use under " + "full load (more than %u). Either grow the limit or " + "change login_max_processes_count and " + "mail_max_processes settings", + (int)rlim.rlim_cur, fd_count); + } +#endif +} + bool master_settings_read(const char *path, bool nochecks, bool nofixes) { struct settings_parse_ctx ctx; @@ -1489,6 +1519,9 @@ return FALSE; } + if (!nochecks) + settings_warn_needed_fds(ctx.root); + /* settings ok, swap them */ temp = settings_pool; settings_pool = settings2_pool;