dovecot-2.0: lib-sql: Fixed load balancing between multiple SQL ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 16 12:21:13 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/327698228158
changeset: 12925:327698228158
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 16 12:21:02 2011 +0300
description:
lib-sql: Fixed load balancing between multiple SQL hosts to actually work.

diffstat:

 src/lib-sql/driver-sqlpool.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (23 lines):

diff -r 79d54b6ccfe1 -r 327698228158 src/lib-sql/driver-sqlpool.c
--- a/src/lib-sql/driver-sqlpool.c	Fri Sep 16 12:11:25 2011 +0300
+++ b/src/lib-sql/driver-sqlpool.c	Fri Sep 16 12:21:02 2011 +0300
@@ -303,7 +303,7 @@
 
 	conns = array_get(&db->all_connections, &count);
 	for (i = 0; i < count; i++) {
-		unsigned int idx = (i + db->last_query_conn_idx) % count;
+		unsigned int idx = (i + db->last_query_conn_idx + 1) % count;
 		struct sql_db *conndb = conns[idx].db;
 
 		if (conns[idx].host_idx == unwanted_host_idx)
@@ -526,8 +526,8 @@
 		ret2 = conn->db->to_reconnect != NULL ? -1 :
 			sql_connect(conn->db);
 		if (ret2 > 0)
-			return 1;
-		if (ret2 == 0)
+			ret = 1;
+		else if (ret2 == 0 && ret < 0)
 			ret = 0;
 	}
 	return ret;


More information about the dovecot-cvs mailing list