[dovecot-cvs] dovecot/src/imap-login client.c,1.51.2.1,1.51.2.2
cras at dovecot.org
cras at dovecot.org
Sun Aug 6 23:05:26 EEST 2006
Update of /var/lib/cvs/dovecot/src/imap-login
In directory talvi:/tmp/cvs-serv2858/src/imap-login
Modified Files:
Tag: branch_1_0
client.c
Log Message:
Fixes to login process handling, especially with
login_process_per_connection=no. Removed login_max_logging_users setting
since it was somewhat weird in how it worked. Added login_max_connections to
replace it with login_process_per_connection=no, and with =yes its
functionality is now within login_max_processes_count.
Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap-login/client.c,v
retrieving revision 1.51.2.1
retrieving revision 1.51.2.2
diff -u -d -r1.51.2.1 -r1.51.2.2
--- client.c 1 Jul 2006 20:09:06 -0000 1.51.2.1
+++ client.c 6 Aug 2006 20:05:23 -0000 1.51.2.2
@@ -121,7 +121,8 @@
&client->common.proxy);
if (fd_ssl == -1) {
client_send_line(client, "* BYE TLS initialization failed.");
- client_destroy(client, "TLS initialization failed.");
+ client_destroy(client,
+ "Disconnected: TLS initialization failed.");
return;
}
@@ -358,16 +359,18 @@
struct hash_iterate_context *iter;
void *key, *value;
struct imap_client *destroy_buf[CLIENT_DESTROY_OLDEST_COUNT];
- int i;
+ unsigned int i, destroy_count;
/* find the oldest clients and put them to destroy-buffer */
memset(destroy_buf, 0, sizeof(destroy_buf));
+ destroy_count = max_connections > CLIENT_DESTROY_OLDEST_COUNT*2 ?
+ CLIENT_DESTROY_OLDEST_COUNT : I_MIN(max_connections/2, 1);
iter = hash_iterate_init(clients);
while (hash_iterate(iter, &key, &value)) {
struct imap_client *client = key;
- for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
+ for (i = 0; i < destroy_count; i++) {
if (destroy_buf[i] == NULL ||
destroy_buf[i]->created > client->created) {
/* @UNSAFE */
@@ -382,7 +385,7 @@
hash_iterate_deinit(iter);
/* then kill them */
- for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
+ for (i = 0; i < destroy_count; i++) {
if (destroy_buf[i] == NULL)
break;
@@ -411,12 +414,22 @@
const struct ip_addr *ip)
{
struct imap_client *client;
+ unsigned int current_count;
- if (max_logging_users > CLIENT_DESTROY_OLDEST_COUNT &&
- hash_size(clients) >= max_logging_users) {
- /* reached max. users count, kill few of the
- oldest connections */
- client_destroy_oldest();
+ if (!process_per_connection) {
+ current_count = hash_size(clients) +
+ ssl_proxy_get_count() + login_proxy_get_count();
+ if (current_count >= max_connections) {
+ /* already reached max. users count, kill few of the
+ oldest connections. this happens when we've maxed
+ out the login process count also. */
+ client_destroy_oldest();
+ }
+ if (current_count + 1 >= max_connections) {
+ /* after this client we've reached max users count,
+ so stop listening for more */
+ main_listen_stop();
+ }
}
/* always use nonblocking I/O */
@@ -444,7 +457,6 @@
client_send_greeting(client);
client_set_title(client);
- client->created = TRUE;
return &client->common;
}
@@ -500,6 +512,8 @@
client->common.proxy = NULL;
}
client_unref(client);
+
+ main_listen_start();
}
void client_destroy_internal_failure(struct imap_client *client)
@@ -617,7 +631,7 @@
while (hash_iterate(iter, &key, &value)) {
struct imap_client *client = key;
- client_destroy(client, NULL);
+ client_destroy(client, "Disconnected: Shutting down");
}
hash_iterate_deinit(iter);
}
More information about the dovecot-cvs
mailing list