From ee977019e39fe33a508a60abe4a3ad7eff819b74 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Mon, 9 Jul 2007 17:02:29 +0200 Subject: libalpm/db.c : add alpm_db_unregister_all. This basically moves the code from alpm_release, which was mostly about unregistering all databases, to a safer alpm_db_unregister_all. This allows to avoid modifying the dbs_sync list while iterating over it, and and also prevent alpm_release from looping infinitely when a database can't be unregistered. Signed-off-by: Chantry Xavier --- lib/libalpm/alpm.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'lib/libalpm/alpm.c') diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index e3ad211d..20d4a746 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -62,24 +62,12 @@ int SYMEXPORT alpm_initialize(void) */ int SYMEXPORT alpm_release(void) { - int dbs_left = 0; - ALPM_LOG_FUNC; ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - /* close local database */ - if(handle->db_local) { - alpm_db_unregister(handle->db_local); - handle->db_local = NULL; - } - /* and also sync ones */ - while((dbs_left = alpm_list_count(handle->dbs_sync)) > 0) { - pmdb_t *db = (pmdb_t *)handle->dbs_sync->data; - _alpm_log(PM_LOG_DEBUG, "removing DB %s, %d remaining...", - db->treename, dbs_left); - alpm_db_unregister(db); - db = NULL; + if(alpm_db_unregister_all() == -1) { + return(-1); } _alpm_handle_free(handle); -- cgit v1.2.3-54-g00ecf