summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_modules.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-03 18:29:58 +1000
committerAndrew Tridgell <tridge@samba.org>2009-09-03 18:36:09 +1000
commitbfccc4590dc94b37258b7225d153c4c01d1a28d6 (patch)
tree901027032373df9aaffc0ee1b3e44c57bd93d46e /source4/lib/ldb/common/ldb_modules.c
parentc37f290043c55ec6428a313b4ec3ca2f91e5e98e (diff)
downloadsamba-bfccc4590dc94b37258b7225d153c4c01d1a28d6.tar.gz
samba-bfccc4590dc94b37258b7225d153c4c01d1a28d6.tar.bz2
samba-bfccc4590dc94b37258b7225d153c4c01d1a28d6.zip
always use prepare_commit in ldb transaction commits if possible
The reason we need this is to make multi-tdb transactions safe, with the partition module. The linked_attributes and repl_meta_data modules now do extra processing when the transaction ends, and that processing can fail. When it fails we need to cancel the transaction, which we can only do if the hook is on the prepare commit instead of the end transaction call. Otherwise the partition module cannot ensure that no commit has been done on another partition.
Diffstat (limited to 'source4/lib/ldb/common/ldb_modules.c')
-rw-r--r--source4/lib/ldb/common/ldb_modules.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 05dffd005a..b792daa913 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -472,10 +472,14 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
which makes writing a module simpler, and makes it more likely to keep working
when ldb is extended
*/
-#define FIND_OP(module, op) do { \
- struct ldb_context *ldb = module->ldb; \
+#define FIND_OP_NOERR(module, op) do { \
module = module->next; \
while (module && module->ops->op == NULL) module = module->next; \
+} while (0)
+
+#define FIND_OP(module, op) do { \
+ struct ldb_context *ldb = module->ldb; \
+ FIND_OP_NOERR(module, op); \
if (module == NULL) { \
ldb_asprintf_errstring(ldb, "Unable to find backend operation for " #op ); \
return LDB_ERR_OPERATIONS_ERROR; \
@@ -595,6 +599,17 @@ int ldb_next_end_trans(struct ldb_module *module)
return module->ops->end_transaction(module);
}
+int ldb_next_prepare_commit(struct ldb_module *module)
+{
+ FIND_OP_NOERR(module, prepare_commit);
+ if (module == NULL) {
+ /* we are allowed to have no prepare commit in
+ backends */
+ return LDB_SUCCESS;
+ }
+ return module->ops->prepare_commit(module);
+}
+
int ldb_next_del_trans(struct ldb_module *module)
{
FIND_OP(module, del_transaction);