dovecot-2.0: sql cache: Free all unused connections at deinit.

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 25 19:18:52 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/9086b081c339
changeset: 11636:9086b081c339
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 25 17:18:46 2010 +0100
description:
sql cache: Free all unused connections at deinit.

diffstat:

 src/lib-sql/sql-db-cache.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r 9127a9f4a020 -r 9086b081c339 src/lib-sql/sql-db-cache.c
--- a/src/lib-sql/sql-db-cache.c	Fri Jun 25 17:02:18 2010 +0100
+++ b/src/lib-sql/sql-db-cache.c	Fri Jun 25 17:18:46 2010 +0100
@@ -67,19 +67,23 @@
 	ctx->cache->unused_count--;
 }
 
-static void sql_db_cache_drop_oldest(struct sql_db_cache *cache)
+static void sql_db_cache_free_tail(struct sql_db_cache *cache)
 {
 	struct sql_db *db;
 	struct sql_db_cache_context *ctx;
 
-	while (cache->unused_count >= cache->max_unused_connections) {
-		db = cache->unused_tail;
-		ctx = SQL_DB_CACHE_CONTEXT(db);
-		sql_db_cache_unlink(ctx);
+	db = cache->unused_tail;
+	ctx = SQL_DB_CACHE_CONTEXT(db);
+	sql_db_cache_unlink(ctx);
 
-		i_free(ctx->key);
-		ctx->orig_deinit(db);
-	}
+	i_free(ctx->key);
+	ctx->orig_deinit(db);
+}
+
+static void sql_db_cache_drop_oldest(struct sql_db_cache *cache)
+{
+	while (cache->unused_count >= cache->max_unused_connections)
+		sql_db_cache_free_tail(cache);
 }
 
 struct sql_db *
@@ -134,6 +138,8 @@
 	struct sql_db_cache *cache = *_cache;
 
 	*_cache = NULL;
+	while (cache->unused_tail != NULL)
+		sql_db_cache_free_tail(cache);
 	hash_table_destroy(&cache->dbs);
 	i_free(cache);
 }


More information about the dovecot-cvs mailing list