[dovecot-cvs] dovecot/src/pop3-login client.c,1.51,1.52

cras at dovecot.org cras at dovecot.org
Sun Aug 6 23:05:40 EEST 2006


Update of /var/lib/cvs/dovecot/src/pop3-login
In directory talvi:/tmp/cvs-serv16539/src/pop3-login

Modified Files:
	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/pop3-login/client.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- client.c	1 Jul 2006 20:09:37 -0000	1.51
+++ client.c	6 Aug 2006 20:05:37 -0000	1.52
@@ -77,7 +77,8 @@
 			       &client->common.proxy);
 	if (fd_ssl == -1) {
 		client_send_line(client, "-ERR TLS initialization failed.");
-		client_destroy(client, "TLS initialization failed.");
+		client_destroy(client,
+			       "Disconnected: TLS initialization failed.");
 		return;
 	}
 
@@ -231,16 +232,18 @@
 	struct hash_iterate_context *iter;
 	void *key, *value;
 	struct pop3_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 pop3_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 */
@@ -255,7 +258,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;
 
@@ -304,12 +307,22 @@
 			     const struct ip_addr *ip)
 {
 	struct pop3_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 */
@@ -388,6 +401,8 @@
 	if (client->common.proxy != NULL)
 		ssl_proxy_free(client->common.proxy);
 	client_unref(client);
+
+	main_listen_start();
 }
 
 void client_destroy_internal_failure(struct pop3_client *client)
@@ -496,7 +511,7 @@
 	while (hash_iterate(iter, &key, &value)) {
 		struct pop3_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