dovecot-1.1: login processes set their fd limit too low, causing...

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 6 19:44:27 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/2a0444413ed7
changeset: 7813:2a0444413ed7
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 06 12:44:14 2008 -0400
description:
login processes set their fd limit too low, causing "too many open files" errors

diffstat:

1 file changed, 6 insertions(+), 1 deletion(-)
src/login-common/main.c |    7 ++++++-

diffs (27 lines):

diff -r d674c05d725d -r 2a0444413ed7 src/login-common/main.c
--- a/src/login-common/main.c	Tue Aug 05 11:24:29 2008 -0400
+++ b/src/login-common/main.c	Wed Aug 06 12:44:14 2008 -0400
@@ -251,6 +251,7 @@ static void drop_privileges(void)
 static void drop_privileges(void)
 {
 	const char *value;
+	unsigned int max_fd_per_conn;
 
 	if (!is_inetd)
 		i_set_failure_internal();
@@ -280,10 +281,14 @@ static void drop_privileges(void)
 	value = getenv("MAX_CONNECTIONS");
 	max_connections = value == NULL ? 1 : strtoul(value, NULL, 10);
 
+	/* max fds: connection itself, SSL socketpair, login proxy socketpair */
+	max_fd_per_conn = 1 + (ssl_initialized ? 2 : 0) + 2;
+
 	/* set the number of fds we want to use. it may get increased or
 	   decreased. leave a couple of extra fds for auth sockets and such */
 	restrict_fd_limit(LOGIN_MASTER_SOCKET_FD + 16 +
-			  listen_count + ssl_listen_count + max_connections);
+			  listen_count + ssl_listen_count +
+			  max_connections * max_fd_per_conn);
 
 	/* Refuse to run as root - we should never need it and it's
 	   dangerous with SSL. */


More information about the dovecot-cvs mailing list