summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-02 16:20:50 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-02 16:20:50 +0000
commit656a887d3589d1f03378c2d35e511ddc178e6a40 (patch)
treeb4867ee5cee2d0651c1c362580d589719ea4bf0b /lib
parent316cd2b573ff805225d7bb99e93459448088fb31 (diff)
more sanity checks: do not add or remove databases while a trasaction is running
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 510d898e..b17a7c49 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -167,6 +167,8 @@ pmdb_t *alpm_db_register(char *treename)
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL));
ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL));
+ /* Do not register a database if a transaction is on-going */
+ ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
if(strcmp(treename, "local") == 0) {
if(handle->db_local != NULL) {
@@ -221,6 +223,8 @@ int alpm_db_unregister(pmdb_t *db)
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ /* Do not unregister a database if a transaction is on-going */
+ ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
if(db == handle->db_local) {
db_close(handle->db_local);
@@ -267,6 +271,8 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ /* Do not update a database if a transaction is on-going */
+ ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
if(!pm_list_is_in(db, handle->dbs_sync)) {
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);