dovecot-2.1: lib-sql: Connect to all configured hosts immediately.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Sep 16 16:59:32 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/55552b4e8c65
changeset: 13493:55552b4e8c65
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 15 13:47:44 2011 +0300
description:
lib-sql: Connect to all configured hosts immediately.
This makes load balancing between them actually work always.
diffstat:
src/lib-sql/driver-sqlpool.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 1b829680dce4 -r 55552b4e8c65 src/lib-sql/driver-sqlpool.c
--- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300
+++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:47:44 2011 +0300
@@ -447,6 +447,19 @@
db->connection_limit = SQL_DEFAULT_CONNECTION_LIMIT;
}
+static void sqlpool_add_all_once(struct sqlpool_db *db)
+{
+ struct sqlpool_host *host;
+ unsigned int host_idx;
+
+ for (;;) {
+ host = sqlpool_find_host_with_least_connections(db, &host_idx);
+ if (host->connection_count > 0)
+ break;
+ (void)sqlpool_add_connection(db, host, host_idx);
+ }
+}
+
struct sql_db *
driver_sqlpool_init(const char *connect_string, const struct sql_db *driver)
{
@@ -465,8 +478,8 @@
} T_END;
i_array_init(&db->all_connections, 16);
- /* always have at least one backend connection initialized */
- (void)sqlpool_add_new_connection(db);
+ /* connect to all databases so we can do load balancing immediately */
+ sqlpool_add_all_once(db);
return &db->api;
}
More information about the dovecot-cvs
mailing list