From: Timo Sirainen Date: Thu, 15 Jan 2009 21:22:04 +0000 (-0500) Subject: login processes: Tell ioloop the maximum number of fds we can use. X-Git-Tag: 1.2.beta1~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=26938703a2b5a6fc1a6f410e5f6b643a63beabb9;p=thirdparty%2Fdovecot%2Fcore.git login processes: Tell ioloop the maximum number of fds we can use. --HG-- branch : HEAD --- diff --git a/src/login-common/main.c b/src/login-common/main.c index 40ff0d5fd1..26ac2245d3 100644 --- a/src/login-common/main.c +++ b/src/login-common/main.c @@ -252,7 +252,7 @@ static void auth_connect_notify(struct auth_client *client ATTR_UNUSED, clients_notify_auth_connected(); } -static void drop_privileges(void) +static void drop_privileges(unsigned int *max_fds_r) { const char *value; @@ -287,9 +287,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. */ @@ -393,7 +393,7 @@ int main(int argc ATTR_UNUSED, char *argv[], char *envp[]) { 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; @@ -442,10 +442,11 @@ int main(int argc ATTR_UNUSED, char *argv[], char *envp[]) 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) {