summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-07-04 16:15:11 +0200
committerMichael Adam <obnox@samba.org>2011-07-04 20:02:09 +0200
commit1621aab139f0104cb2c7183c28c52cb6605abb09 (patch)
treea18800fa36abb87d56651de84e675c175c21b43b
parentcaf9c9996952e72e61f9c9f0efd27936f38eefda (diff)
downloadsamba-1621aab139f0104cb2c7183c28c52cb6605abb09.tar.gz
samba-1621aab139f0104cb2c7183c28c52cb6605abb09.tar.bz2
samba-1621aab139f0104cb2c7183c28c52cb6605abb09.zip
s3:registry: wrap the whole db upgrade in one transaction
The purpose of this is to prepare for multiple upgrade steps to be performed in a single transaction, so that no change at all is made to that database if one step fails. Pair-Programmed-With: Gregor Beck <gbeck@sernet.de>
-rw-r--r--source3/registry/reg_backend_db.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 5c7f48923f..e87ae649ce 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -507,29 +507,29 @@ WERROR regdb_init(void)
return WERR_CAN_NOT_COMPLETE;
}
+ if (regdb->transaction_start(regdb) != 0) {
+ return WERR_REG_IO_FAILURE;
+ }
+
if (vers_id == REGVER_V1) {
DEBUG(10, ("regdb_init: got registry db version %d, upgrading "
"to version %d\n", REGVER_V1, REGVER_V2));
- if (regdb->transaction_start(regdb) != 0) {
- return WERR_REG_IO_FAILURE;
- }
-
werr = regdb_upgrade_v1_to_v2();
if (!W_ERROR_IS_OK(werr)) {
regdb->transaction_cancel(regdb);
return werr;
}
- if (regdb->transaction_commit(regdb) != 0) {
- return WERR_REG_IO_FAILURE;
- }
-
vers_id = REGVER_V2;
}
/* future upgrade code should go here */
+ if (regdb->transaction_commit(regdb) != 0) {
+ return WERR_REG_IO_FAILURE;
+ }
+
return WERR_OK;
}