changeset 7967:6d9f2185b9e0 HEAD

pgsql: Don't break with synchronous queries (with dict-sql)
author Timo Sirainen <tss@iki.fi>
date Tue, 08 Jul 2008 13:49:35 +0530
parents 54225d0b6e2b
children 47483377feb4
files src/lib-sql/driver-pgsql.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-sql/driver-pgsql.c	Mon Jul 07 18:44:16 2008 +0530
+++ b/src/lib-sql/driver-pgsql.c	Tue Jul 08 13:49:35 2008 +0530
@@ -208,7 +208,7 @@
 		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 @@
         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 @@
 				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 @@
 		}
 		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);