dsdb: The schema should be reloaded during the transaction
authorGarming Sam <garming@catalyst.net.nz>
Mon, 20 Nov 2017 22:31:10 +0000 (11:31 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 5 Mar 2018 19:50:15 +0000 (20:50 +0100)
Reload the schema just after getting the tranaction lock
but before the transaction counter is bumped.

This ensures we reload the schema exactly once but with
the DB locked.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/schema_load.c

index 2d712e2c6df23079b44db10ccf464f55c8fcd8ef..2099fac1159ed59104bef185a4417e61db635473 100644 (file)
@@ -572,6 +572,12 @@ static int schema_load_start_transaction(struct ldb_module *module)
                talloc_get_type(ldb_module_get_private(module), struct schema_load_private_data);
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct dsdb_schema *schema;
+       int ret;
+
+       ret = ldb_next_start_trans(module);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
 
        /* Try the schema refresh now */
        schema = dsdb_get_schema(ldb, NULL);
@@ -582,7 +588,7 @@ static int schema_load_start_transaction(struct ldb_module *module)
        }
        private_data->in_transaction++;
 
-       return ldb_next_start_trans(module);
+       return ret;
 }
 
 static int schema_load_end_transaction(struct ldb_module *module)