summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-23 22:46:09 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-25 13:15:18 +1100
commitc34e45a8e2880eb06be6425fa6be15246db03197 (patch)
tree5e54e1d14f99fffb90a32a2819086df212728609 /source4/dsdb
parentd4c0e8fdf063f88032c32de7ece60d502b322089 (diff)
downloadsamba-c34e45a8e2880eb06be6425fa6be15246db03197.tar.gz
samba-c34e45a8e2880eb06be6425fa6be15246db03197.tar.bz2
samba-c34e45a8e2880eb06be6425fa6be15246db03197.zip
s4-dsdb: ensure that new partitions inherit any transaction
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c15
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.h1
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition_init.c21
3 files changed, 26 insertions, 11 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 779b8b5a35..64015ed7b1 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -690,6 +690,9 @@ static int partition_start_trans(struct ldb_module *module)
return ret;
}
}
+
+ data->in_transaction++;
+
return LDB_SUCCESS;
}
@@ -737,6 +740,12 @@ static int partition_end_trans(struct ldb_module *module)
}
}
+ if (data->in_transaction == 0) {
+ DEBUG(0,("partition end transaction mismatch\n"));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ data->in_transaction--;
+
return ldb_next_end_trans(module);
}
@@ -756,6 +765,12 @@ static int partition_del_trans(struct ldb_module *module)
}
}
+ if (data->in_transaction == 0) {
+ DEBUG(0,("partition del transaction mismatch\n"));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ data->in_transaction--;
+
ret = ldb_next_del_trans(module);
if (ret != LDB_SUCCESS) {
final_ret = ret;
diff --git a/source4/dsdb/samdb/ldb_modules/partition.h b/source4/dsdb/samdb/ldb_modules/partition.h
index 3572f17109..dda0b86515 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.h
+++ b/source4/dsdb/samdb/ldb_modules/partition.h
@@ -45,6 +45,7 @@ struct partition_private_data {
const char *ldapBackend;
uint64_t metadata_seq;
+ uint32_t in_transaction;
};
#define PARTITION_FIND_OP_NOERROR(module, op) do { \
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index 28eab9b2ee..5967bc8159 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -282,6 +282,16 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_steal((*partition), (*partition)->module);
+ /* if we were in a transaction then we need to start a
+ transaction on this new partition, otherwise we'll get a
+ transaction mismatch when we end the transaction */
+ if (data->in_transaction) {
+ struct ldb_module *next = (*partition)->module;
+ PARTITION_FIND_OP(next, start_transaction);
+
+ ret = next->ops->start_transaction(next);
+ }
+
return ret;
}
@@ -698,17 +708,6 @@ int partition_create(struct ldb_module *module, struct ldb_request *req)
if (ret != LDB_SUCCESS) {
return ret;
}
-
- /* Start a transaction on the DB (as it won't be in one being brand new) */
- {
- struct ldb_module *next = partition->module;
- PARTITION_FIND_OP(next, start_transaction);
-
- ret = next->ops->start_transaction(next);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
}
ret = new_partition_set_replicated_metadata(ldb, module, last_req, data, partition);