[dovecot-cvs] dovecot/src/lib-auth auth-server-connection.c, 1.11, 1.12 auth-server-connection.h, 1.7, 1.8

cras at dovecot.org cras at dovecot.org
Wed Dec 15 19:52:19 EET 2004


Update of /var/lib/cvs/dovecot/src/lib-auth
In directory talvi:/tmp/cvs-serv22416/lib-auth

Modified Files:
	auth-server-connection.c auth-server-connection.h 
Log Message:
Connect to available auth sockets by round robin.



Index: auth-server-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-auth/auth-server-connection.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- auth-server-connection.c	22 Oct 2004 13:42:55 -0000	1.11
+++ auth-server-connection.c	15 Dec 2004 17:52:17 -0000	1.12
@@ -321,18 +321,35 @@
 auth_server_connection_find_mech(struct auth_client *client,
 				 const char *name, const char **error_r)
 {
-	struct auth_server_connection *conn;
+	struct auth_server_connection *conn, *match;
 	const struct auth_mech_desc *mech;
-	unsigned int i;
+	unsigned int i, n, match_n;
 
-	for (conn = client->connections; conn != NULL; conn = conn->next) {
+	/* find a connection which has this mechanism. if there are multiple
+	   available connections to use, do round robin load balancing */
+	match = NULL; match_n = n = 0;
+	for (conn = client->connections; conn != NULL; conn = conn->next, n++) {
 		mech = conn->available_auth_mechs;
 		for (i = 0; i < conn->available_auth_mechs_count; i++) {
-			if (strcasecmp(mech[i].name, name) == 0)
-				return conn;
+			if (strcasecmp(mech[i].name, name) == 0) {
+				if (n > client->last_used_auth_process) {
+					client->last_used_auth_process = n;
+					return conn;
+				}
+				if (match == NULL) {
+					match = conn;
+					match_n = n;
+				}
+				break;
+			}
 		}
 	}
 
+	if (match != NULL) {
+		client->last_used_auth_process = match_n;
+		return match;
+	}
+
 	if (auth_client_find_mech(client, name) == NULL)
 		*error_r = "Unsupported authentication mechanism";
 	else {

Index: auth-server-connection.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-auth/auth-server-connection.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- auth-server-connection.h	19 Oct 2004 00:51:21 -0000	1.7
+++ auth-server-connection.h	15 Dec 2004 17:52:17 -0000	1.8
@@ -15,6 +15,7 @@
 
 	buffer_t *available_auth_mechs;
 	unsigned int request_id_counter;
+	unsigned int last_used_auth_process;
 
 	auth_connect_notify_callback_t *connect_notify_callback;
 	void *connect_notify_context;



More information about the dovecot-cvs mailing list