dovecot-1.1: login processes: Tell ioloop the maximum number of ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jan 15 23:22:28 EET 2009


details:   http://hg.dovecot.org/dovecot-1.1/rev/60b4e34791c4
changeset: 8101:60b4e34791c4
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jan 15 16:22:04 2009 -0500
description:
login processes: Tell ioloop the maximum number of fds we can use.

diffstat:

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

diffs (47 lines):

diff -r 66687cb6951c -r 60b4e34791c4 src/login-common/main.c
--- a/src/login-common/main.c	Thu Jan 15 16:20:52 2009 -0500
+++ b/src/login-common/main.c	Thu Jan 15 16:22:04 2009 -0500
@@ -251,7 +251,7 @@ static void auth_connect_notify(struct a
                 clients_notify_auth_connected();
 }
 
-static void drop_privileges(void)
+static void drop_privileges(unsigned int *max_fds_r)
 {
 	const char *value;
 
@@ -286,9 +286,9 @@ static void drop_privileges(void)
 	/* 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.
 	   normal connections each use one fd, but SSL connections use two */
-	restrict_fd_limit(LOGIN_MASTER_SOCKET_FD + 16 +
-			  listen_count + ssl_listen_count +
-			  max_connections*2);
+	*max_fds_r = LOGIN_MASTER_SOCKET_FD + 16 +
+		listen_count + ssl_listen_count + max_connections*2;
+	restrict_fd_limit(*max_fds_r);
 
 	/* Refuse to run as root - we should never need it and it's
 	   dangerous with SSL. */
@@ -389,7 +389,7 @@ int main(int argc ATTR_UNUSED, char *arg
 {
 	const char *group_name;
 	struct ip_addr remote_ip, local_ip;
-	unsigned int remote_port, local_port;
+	unsigned int remote_port, local_port, max_fds;
 	struct ssl_proxy *proxy = NULL;
 	struct client *client;
 	int i, fd = -1, master_fd = -1;
@@ -438,10 +438,11 @@ int main(int argc ATTR_UNUSED, char *arg
 		master_fd = master_connect(group_name);
 	}
 
-	drop_privileges();
+	drop_privileges(&max_fds);
 
 	process_title_init(argv, envp);
 	ioloop = io_loop_create();
+	io_loop_set_max_fd_count(ioloop, max_fds);
 	main_init();
 
 	if (is_inetd) {


More information about the dovecot-cvs mailing list