summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/partition_init.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-10-14 12:57:03 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-10-21 22:43:52 +1100
commite62200e253a393ce0a427ff315267efbd2eaeeea (patch)
tree263e213ca3b732f3566fef86dee0ba6cd08d7668 /source4/dsdb/samdb/ldb_modules/partition_init.c
parent18035251add0e8c39f5fe7976881d6fd32c1bb9a (diff)
downloadsamba-e62200e253a393ce0a427ff315267efbd2eaeeea.tar.gz
samba-e62200e253a393ce0a427ff315267efbd2eaeeea.tar.bz2
samba-e62200e253a393ce0a427ff315267efbd2eaeeea.zip
s4:dsdb Reload partition metadata if the main db updates
This uses the fact that the primary DB does not change often. Before each operation, we see if the sequence number has changed. Andrew Bartlett
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/partition_init.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition_init.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index cfec1aa585..2da938d20e 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -159,6 +159,38 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
return LDB_SUCCESS;
}
+int partition_reload_if_required(struct ldb_module *module,
+ struct partition_private_data *data)
+
+{
+ uint64_t seq;
+ int ret;
+ TALLOC_CTX *mem_ctx = talloc_new(data);
+ if (!data) {
+ /* Not initilised yet */
+ return LDB_SUCCESS;
+ }
+ if (!mem_ctx) {
+ ldb_oom(ldb_module_get_ctx(module));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ret = partition_primary_sequence_number(module, mem_ctx, LDB_SEQ_HIGHEST_SEQ, &seq);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(mem_ctx);
+ return ret;
+ }
+ if (seq != data->metadata_seq) {
+ ret = partition_reload_metadata(module, data, mem_ctx, NULL);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(mem_ctx);
+ return ret;
+ }
+ data->metadata_seq = seq;
+ }
+ talloc_free(mem_ctx);
+ return LDB_SUCCESS;
+}
+
static const char **find_modules_for_dn(struct partition_private_data *data, struct ldb_dn *dn)
{
int i;
@@ -577,6 +609,12 @@ int partition_init(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
+ ret = partition_primary_sequence_number(module, mem_ctx, LDB_SEQ_HIGHEST_SEQ, &data->metadata_seq);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(mem_ctx);
+ return ret;
+ }
+
ret = partition_reload_metadata(module, data, mem_ctx, &msg);
if (ret != LDB_SUCCESS) {
return ret;