Mercurial > dovecot > core-2.2
changeset 12690:f043ef71b936
pgsql: When executing synchronous queries, don't wrongly add a connect timeout.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Jan 2011 21:37:24 +0200 |
parents | 73a889098495 |
children | ed675e34dfa7 |
files | src/lib-sql/driver-pgsql.c |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-sql/driver-pgsql.c Sun Jan 09 21:13:31 2011 +0200 +++ b/src/lib-sql/driver-pgsql.c Sun Jan 09 21:37:24 2011 +0200 @@ -526,6 +526,8 @@ static void driver_pgsql_sync_init(struct pgsql_db *db) { + bool add_to_connect; + db->orig_ioloop = current_ioloop; if (db->io == NULL) { db->ioloop = io_loop_create(); @@ -536,12 +538,18 @@ /* have to move our existing I/O and timeout handlers to new I/O loop */ io_remove(&db->io); - if (db->to_connect != NULL) + if (db->to_connect != NULL) { timeout_remove(&db->to_connect); + add_to_connect = TRUE; + } else { + add_to_connect = FALSE; + } db->ioloop = io_loop_create(); - db->to_connect = timeout_add(SQL_CONNECT_TIMEOUT_SECS * 1000, - driver_pgsql_connect_timeout, db); + if (add_to_connect) { + db->to_connect = timeout_add(SQL_CONNECT_TIMEOUT_SECS * 1000, + driver_pgsql_connect_timeout, db); + } db->io = io_add(PQsocket(db->pg), db->io_dir, connect_callback, db); /* wait for connecting to finish */ io_loop_run(db->ioloop);