From 6c9e658ec1bb959e20aaab6244daf27dd6232fe2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 11 Apr 2018 11:58:22 +1200 Subject: [PATCH] dsdb: Load schema during the read_lock() hook, not the search This should trigger slightly less often and is the more correct place, as we only load it during the first lock when not in a transaction. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- source4/dsdb/samdb/ldb_modules/schema_load.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c index 55fb63a0f30..9ed363a5973 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_load.c +++ b/source4/dsdb/samdb/ldb_modules/schema_load.c @@ -518,16 +518,6 @@ static int schema_load_init(struct ldb_module *module) return schema_load(ldb, module, &private_data->need_write); } -static int schema_search(struct ldb_module *module, struct ldb_request *req) -{ - struct ldb_context *ldb = ldb_module_get_ctx(module); - - /* Try the schema refresh now */ - dsdb_get_schema(ldb, NULL); - - return ldb_next_request(module, req); -} - static int schema_load_start_transaction(struct ldb_module *module) { struct schema_load_private_data *private_data = @@ -632,8 +622,10 @@ static int schema_read_lock(struct ldb_module *module) return ldb_next_read_lock(module); } + private_data->in_read_transaction++; + if (private_data->in_transaction == 0 && - private_data->in_read_transaction == 0) { + private_data->in_read_transaction == 1) { /* * This appears to fail during the init path, so do not bother * checking the return, and return 0 (reload schema). @@ -643,8 +635,10 @@ static int schema_read_lock(struct ldb_module *module) &schema_seq_num, 0); private_data->schema_seq_num_read_lock = schema_seq_num; + + /* Try the schema refresh now */ + dsdb_get_schema(ldb_module_get_ctx(module), NULL); } - private_data->in_read_transaction++; return ldb_next_read_lock(module); @@ -673,7 +667,6 @@ static const struct ldb_module_ops ldb_schema_load_module_ops = { .name = "schema_load", .init_context = schema_load_init, .extended = schema_load_extended, - .search = schema_search, .start_transaction = schema_load_start_transaction, .end_transaction = schema_load_end_transaction, .del_transaction = schema_load_del_transaction, -- 2.34.1