dovecot-2.0: lib-sql: Don't try to reconnect on deinit or intent...
dovecot at dovecot.org
dovecot at dovecot.org
Fri May 28 13:47:47 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/f9e5c73a988b
changeset: 11407:f9e5c73a988b
user: Timo Sirainen <tss at iki.fi>
date: Fri May 28 11:47:42 2010 +0100
description:
lib-sql: Don't try to reconnect on deinit or intentional disconnect. Fixes a timeout leak.
diffstat:
src/lib-sql/driver-mysql.c | 1 +
src/lib-sql/driver-pgsql.c | 3 +++
src/lib-sql/driver-sqlite.c | 1 +
src/lib-sql/driver-sqlpool.c | 3 ++-
src/lib-sql/sql-api-private.h | 2 ++
5 files changed, 9 insertions(+), 1 deletions(-)
diffs (68 lines):
diff -r 8c521fd311c6 -r f9e5c73a988b src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c Fri May 28 11:46:55 2010 +0100
+++ b/src/lib-sql/driver-mysql.c Fri May 28 11:47:42 2010 +0100
@@ -203,6 +203,7 @@
{
struct mysql_db *db = (struct mysql_db *)_db;
+ _db->no_reconnect = TRUE;
sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED);
mysql_close(db->mysql);
diff -r 8c521fd311c6 -r f9e5c73a988b src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c Fri May 28 11:46:55 2010 +0100
+++ b/src/lib-sql/driver-pgsql.c Fri May 28 11:47:42 2010 +0100
@@ -197,7 +197,9 @@
{
struct pgsql_db *db = (struct pgsql_db *)_db;
+ _db->no_reconnect = TRUE;
driver_pgsql_close(db);
+ _db->no_reconnect = FALSE;
}
static struct sql_db *driver_pgsql_init_v(const char *connect_string)
@@ -217,6 +219,7 @@
if (db->cur_result != NULL && db->cur_result->to != NULL)
result_finish(db->cur_result);
+ _db->no_reconnect = TRUE;
driver_pgsql_close(db);
i_free(db->error);
i_free(db->connect_string);
diff -r 8c521fd311c6 -r f9e5c73a988b src/lib-sql/driver-sqlite.c
--- a/src/lib-sql/driver-sqlite.c Fri May 28 11:46:55 2010 +0100
+++ b/src/lib-sql/driver-sqlite.c Fri May 28 11:47:42 2010 +0100
@@ -88,6 +88,7 @@
{
struct sqlite_db *db = (struct sqlite_db *)_db;
+ _db->no_reconnect = TRUE;
sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED);
sqlite3_close(db->sqlite);
diff -r 8c521fd311c6 -r f9e5c73a988b src/lib-sql/driver-sqlpool.c
--- a/src/lib-sql/driver-sqlpool.c Fri May 28 11:46:55 2010 +0100
+++ b/src/lib-sql/driver-sqlpool.c Fri May 28 11:47:42 2010 +0100
@@ -188,7 +188,8 @@
}
if (prev_state == SQL_DB_STATE_CONNECTING &&
- conndb->state == SQL_DB_STATE_DISCONNECTED) {
+ conndb->state == SQL_DB_STATE_DISCONNECTED &&
+ !conndb->no_reconnect) {
/* connect failed */
if (conndb->connect_failure_count > 0) {
/* increase delay between reconnections to this
diff -r 8c521fd311c6 -r f9e5c73a988b src/lib-sql/sql-api-private.h
--- a/src/lib-sql/sql-api-private.h Fri May 28 11:46:55 2010 +0100
+++ b/src/lib-sql/sql-api-private.h Fri May 28 11:47:42 2010 +0100
@@ -97,6 +97,8 @@
unsigned int connect_delay;
unsigned int connect_failure_count;
struct timeout *to_reconnect;
+
+ unsigned int no_reconnect:1;
};
struct sql_result_vfuncs {
More information about the dovecot-cvs
mailing list