[dovecot-cvs] dovecot/src/login-common client-common.h, 1.9, 1.10 common.h, 1.11, 1.12 main.c, 1.36, 1.37

cras at dovecot.org cras at dovecot.org
Fri Aug 11 00:15:03 EEST 2006


Update of /var/lib/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv17141/login-common

Modified Files:
	client-common.h common.h main.c 
Log Message:
Fixes for handling near-full connection queues.



Index: client-common.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- client-common.h	13 Jan 2006 20:26:39 -0000	1.9
+++ client-common.h	10 Aug 2006 21:14:57 -0000	1.10
@@ -33,6 +33,7 @@
 
 unsigned int clients_get_count(void);
 void clients_notify_auth_connected(void);
+void client_destroy_oldest(void);
 void clients_destroy_all(void);
 
 void clients_init(void);

Index: common.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/common.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- common.h	6 Aug 2006 20:05:35 -0000	1.11
+++ common.h	10 Aug 2006 21:14:57 -0000	1.12
@@ -27,4 +27,6 @@
 void main_listen_start(void);
 void main_listen_stop(void);
 
+void connection_queue_add(unsigned int connection_count);
+
 #endif

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- main.c	10 Aug 2006 18:46:59 -0000	1.36
+++ main.c	10 Aug 2006 21:14:57 -0000	1.37
@@ -184,6 +184,33 @@
 				   LOGIN_STATE_FULL_PRELOGINS);
 }
 
+void connection_queue_add(unsigned int connection_count)
+{
+	unsigned int current_count;
+
+	if (process_per_connection)
+		return;
+
+	current_count = clients_get_count() + ssl_proxy_get_count() +
+		login_proxy_get_count();
+	if (current_count + connection_count + 1 >= max_connections) {
+		/* after this client we've reached max users count,
+		   so stop listening for more. reserve +1 extra for SSL
+		   connections. */
+		main_listen_stop();
+
+		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 and master has told us to start listening for
+			   new connections even though we're full. */
+			client_destroy_oldest();
+		}
+	}
+}
+
 static void auth_connect_notify(struct auth_client *client __attr_unused__,
 				bool connected, void *context __attr_unused__)
 {



More information about the dovecot-cvs mailing list