dovecot-2.1: lib-sql: When escaping a string, use the first read...
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/1b829680dce4
changeset: 13492:1b829680dce4
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 15 13:46:45 2011 +0300
description:
lib-sql: When escaping a string, use the first ready connection (if any).
This avoids unnecessarily trying to reconnect to a failing connection.
diffstat:
src/lib-sql/driver-sqlpool.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diffs (26 lines):
diff -r 11273f581686 -r 1b829680dce4 src/lib-sql/driver-sqlpool.c
--- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:45:35 2011 +0300
+++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300
@@ -533,11 +533,18 @@
driver_sqlpool_escape_string(struct sql_db *_db, const char *string)
{
struct sqlpool_db *db = (struct sqlpool_db *)_db;
- const struct sqlpool_connection *conn;
+ const struct sqlpool_connection *conns;
+ unsigned int i, count;
- /* we always have at least one connection */
- conn = array_idx(&db->all_connections, 0);
- return sql_escape_string(conn->db, string);
+ /* use the first ready connection */
+ conns = array_get(&db->all_connections, &count);
+ for (i = 0; i < count; i++) {
+ if (SQL_DB_IS_READY(conns[i].db))
+ return sql_escape_string(conns[i].db, string);
+ }
+ /* no ready connections. just use the first one (we're guaranteed
+ to always have one) */
+ return sql_escape_string(conns[0].db, string);
}
static void driver_sqlpool_timeout(struct sqlpool_db *db)
More information about the dovecot-cvs
mailing list