dovecot: Calculate how many log fds login+mail processes can use...

dovecot at dovecot.org dovecot at dovecot.org
Sat Sep 15 17:02:38 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/e41718b974d2
changeset: 6398:e41718b974d2
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Sep 15 16:59:08 2007 +0300
description:
Calculate how many log fds login+mail processes can use. If it's lower than
the current fd limit, log a warning.

diffstat:

1 file changed, 33 insertions(+)
src/master/master-settings.c |   33 +++++++++++++++++++++++++++++++++

diffs (50 lines):

diff -r 08eaa53f1aaa -r e41718b974d2 src/master/master-settings.c
--- 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 @@ static bool parse_section(const char *ty
 	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 @@ bool master_settings_read(const char *pa
 		return FALSE;
 	}
 
+	if (!nochecks)
+		settings_warn_needed_fds(ctx.root);
+
 	/* settings ok, swap them */
 	temp = settings_pool;
 	settings_pool = settings2_pool;


More information about the dovecot-cvs mailing list