]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pgsql: Don't break with synchronous queries (with dict-sql)
authorTimo Sirainen <tss@iki.fi>
Tue, 8 Jul 2008 08:19:35 +0000 (13:49 +0530)
committerTimo Sirainen <tss@iki.fi>
Tue, 8 Jul 2008 08:19:35 +0000 (13:49 +0530)
--HG--
branch : HEAD

src/lib-sql/driver-pgsql.c

index 5c2085be9d4254445c4665193033f04ad645a4d1..8dfbb9f0160dfe04c614ba04808cb5b3bcc24e6f 100644 (file)
@@ -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);