From: Timo Sirainen Date: Mon, 23 Aug 2010 14:58:53 +0000 (+0100) Subject: lib-sql: sql_disconnect() now aborts all pending requests. X-Git-Tag: 2.0.1~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9349a0afffad990e45d3ad33081e1d2d9e68a753;p=thirdparty%2Fdovecot%2Fcore.git lib-sql: sql_disconnect() now aborts all pending requests. --- diff --git a/src/lib-sql/driver-pgsql.c b/src/lib-sql/driver-pgsql.c index 54c508ccf1..240a549b9f 100644 --- a/src/lib-sql/driver-pgsql.c +++ b/src/lib-sql/driver-pgsql.c @@ -214,6 +214,9 @@ static void driver_pgsql_disconnect(struct sql_db *_db) { struct pgsql_db *db = (struct pgsql_db *)_db; + if (db->cur_result != NULL && db->cur_result->to != NULL) + result_finish(db->cur_result); + _db->no_reconnect = TRUE; driver_pgsql_close(db); _db->no_reconnect = FALSE; diff --git a/src/lib-sql/driver-sqlpool.c b/src/lib-sql/driver-sqlpool.c index 192666e899..41df1a9465 100644 --- a/src/lib-sql/driver-sqlpool.c +++ b/src/lib-sql/driver-sqlpool.c @@ -432,6 +432,17 @@ driver_sqlpool_init(const char *connect_string, const struct sql_db *driver) return &db->api; } +static void driver_sqlpool_abort_requests(struct sqlpool_db *db) +{ + while (db->requests_head != NULL) { + struct sqlpool_request *request = db->requests_head; + + sqlpool_request_abort(&request); + } + if (db->request_to != NULL) + timeout_remove(&db->request_to); +} + static void driver_sqlpool_deinit(struct sql_db *_db) { struct sqlpool_db *db = (struct sqlpool_db *)_db; @@ -442,13 +453,7 @@ static void driver_sqlpool_deinit(struct sql_db *_db) sql_deinit(&conn->db); array_clear(&db->all_connections); - while (db->requests_head != NULL) { - struct sqlpool_request *request = db->requests_head; - - sqlpool_request_abort(&request); - } - if (db->request_to != NULL) - timeout_remove(&db->request_to); + driver_sqlpool_abort_requests(db); array_foreach_modifiable(&db->hosts, host) i_free(host->connect_string); @@ -483,6 +488,7 @@ static void driver_sqlpool_disconnect(struct sql_db *_db) array_foreach(&db->all_connections, conn) sql_disconnect(conn->db); + driver_sqlpool_abort_requests(db); } static const char * diff --git a/src/lib-sql/sql-api.h b/src/lib-sql/sql-api.h index bf8bedb61a..595832d96a 100644 --- a/src/lib-sql/sql-api.h +++ b/src/lib-sql/sql-api.h @@ -65,7 +65,7 @@ enum sql_db_flags sql_get_flags(struct sql_db *db); though. Returns -1 if we're not connected, 0 if we started connecting or 1 if we are fully connected now. */ int sql_connect(struct sql_db *db); -/* Explicitly disconnect from database. */ +/* Explicitly disconnect from database and abort pending auth requests. */ void sql_disconnect(struct sql_db *db); /* Escape the given string if needed and return it. */