summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-05-14 12:54:03 -0400
committerDan McGee <dan@archlinux.org>2011-05-16 10:16:13 -0500
commitb9a2318becfc9d6ffb92e602adf433faa8cec383 (patch)
tree6913704f8476aa8a235aa4f951ad95f74a2a76ed /lib/libalpm
parentb14c5477e5e4483352d304a1e97de5922948b934 (diff)
trans.c: create transaction prior to checking DB version
The addition of the DB version check introduces a lag time between the lockfile creation and the transaction initialization. In cases where the local DB is large enough and/or the user's disk is slow enough, this time is significant enough that its possible for a user to send a SIGINT and leave behind a db.lck file. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/trans.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index c5af7c69..7affbfbd 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -120,15 +120,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
}
}
- /* check database version */
- db_version = _alpm_db_version(handle->db_local);
- if(db_version < required_db_version) {
- _alpm_log(PM_LOG_ERROR,
- _("%s database version is too old\n"), handle->db_local->treename);
- remove_lock(handle);
- RET_ERR(PM_ERR_DB_VERSION, -1);
- }
-
trans = _alpm_trans_new();
if(trans == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
@@ -142,6 +133,16 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
handle->trans = trans;
+ /* check database version */
+ db_version = _alpm_db_version(handle->db_local);
+ if(db_version < required_db_version) {
+ _alpm_log(PM_LOG_ERROR,
+ _("%s database version is too old\n"), handle->db_local->treename);
+ remove_lock(handle);
+ _alpm_trans_free(trans);
+ RET_ERR(PM_ERR_DB_VERSION, -1);
+ }
+
return(0);
}