From: Timo Sirainen Date: Tue, 8 Jul 2008 08:19:35 +0000 (+0530) Subject: pgsql: Don't break with synchronous queries (with dict-sql) X-Git-Tag: 1.2.alpha1~194 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5fe06fea9fee0f5e4e9cb49f6866877223f78b85;p=thirdparty%2Fdovecot%2Fcore.git pgsql: Don't break with synchronous queries (with dict-sql) --HG-- branch : HEAD --- diff --git a/src/lib-sql/driver-pgsql.c b/src/lib-sql/driver-pgsql.c index 5c2085be9d..8dfbb9f016 100644 --- a/src/lib-sql/driver-pgsql.c +++ b/src/lib-sql/driver-pgsql.c @@ -208,7 +208,7 @@ static void driver_pgsql_deinit_v(struct sql_db *_db) db->queue = next; } - if (db->queue_to != 0) + if (db->queue_to != NULL) timeout_remove(&db->queue_to); driver_pgsql_close(db); i_free(db->error); @@ -562,6 +562,12 @@ driver_pgsql_query_s(struct sql_db *_db, const char *query) struct pgsql_db *db = (struct pgsql_db *)_db; struct io old_io; + if (db->queue_to != NULL) { + /* we're creating a new ioloop, make sure the timeout gets + added there. */ + timeout_remove(&db->queue_to); + } + if (db->io == NULL) db->ioloop = io_loop_create(); else { @@ -575,12 +581,6 @@ driver_pgsql_query_s(struct sql_db *_db, const char *query) old_io.callback, old_io.context); } - if (db->queue_to != NULL) { - /* we're creating a new ioloop, make sure the timeout gets - added there. */ - timeout_remove(&db->queue_to); - } - db->query_finished = FALSE; driver_pgsql_query(_db, query, pgsql_query_s_callback, db); @@ -596,6 +596,9 @@ driver_pgsql_query_s(struct sql_db *_db, const char *query) } if (db->queue_to != NULL) timeout_remove(&db->queue_to); + } else { + i_assert(db->io == NULL); + i_assert(db->queue_to == NULL); } io_loop_destroy(&db->ioloop);