summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-22 22:08:36 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-23 15:02:25 +0200
commitd1eac79690d0fe8f8a5a78bcb83a6b4783279e27 (patch)
treee330820d20cb00bc4035cbb30e1ad32ba5344f85 /source4/dsdb
parenta58ac39a5ae97b3aebfde10466798b41baccaacf (diff)
downloadsamba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.tar.gz
samba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.tar.bz2
samba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.zip
s4-dsdb: Do not use a possibly-old loadparm context in schema reload
The loadparm context on the schema DB might have gone away already. Pre-cache the schema refresh interval at load time to avoid worrying about this. Andrew Bartlett
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_load.c10
-rw-r--r--source4/dsdb/schema/schema.h1
-rw-r--r--source4/dsdb/schema/schema_init.c26
3 files changed, 18 insertions, 19 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c
index be7915e03c..f09c47a3ed 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_load.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_load.c
@@ -166,10 +166,7 @@ static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct
struct dsdb_control_current_partition *ctrl;
struct ldb_context *ldb = ldb_module_get_ctx(module);
struct dsdb_schema *new_schema;
- int interval;
- time_t ts, lastts;
- struct loadparm_context *lp_ctx =
- (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm");
+ time_t ts, lastts;
struct schema_load_private_data *private_data = talloc_get_type(ldb_module_get_private(module), struct schema_load_private_data);
if (!private_data) {
@@ -184,9 +181,8 @@ static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct
lastts = schema->last_refresh;
ts = time(NULL);
- interval = lpcfg_parm_int(lp_ctx, NULL, "dsdb", "schema_reload_interval", 120);
- if (lastts > (ts - interval)) {
- DEBUG(11, ("Less than %d seconds since last reload, returning cached version ts = %d\n", interval, (int)lastts));
+ if (lastts > (ts - schema->refresh_interval)) {
+ DEBUG(11, ("Less than %d seconds since last reload, returning cached version ts = %d\n", (int)schema->refresh_interval, (int)lastts));
return schema;
}
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index 81ac129d5e..eb288e6bf9 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -247,6 +247,7 @@ struct dsdb_schema {
bool refresh_in_progress;
time_t ts_last_change;
time_t last_refresh;
+ time_t refresh_interval;
/* This 'opaque' is stored in the metadata and is used to check if the currently
* loaded schema needs a reload because another process has signaled that it has been
* requested to reload the schema (either due through DRS or via the schemaUpdateNow).
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 8385ac2def..752d4f57dd 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -39,6 +39,7 @@ struct dsdb_schema *dsdb_new_schema(TALLOC_CTX *mem_ctx)
if (!schema) {
return NULL;
}
+ schema->refresh_interval = 120;
return schema;
}
@@ -93,6 +94,8 @@ struct dsdb_schema *dsdb_schema_copy_shallow(TALLOC_CTX *mem_ctx,
}
schema_copy->num_attributes = schema->num_attributes;
+ schema_copy->refresh_interval = schema->refresh_interval;
+
/* rebuild indexes */
ret = dsdb_setup_sorted_accessors(ldb, schema_copy);
if (ret != LDB_SUCCESS) {
@@ -840,7 +843,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
const struct ldb_val *info_val;
struct ldb_val info_val_default;
struct dsdb_schema *schema;
- struct loadparm_context *lp_ctx = NULL;
+ void *lp_opaque = ldb_get_opaque(ldb, "loadparm");
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
@@ -856,6 +859,16 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
return ldb_operr(ldb);
}
+ if (lp_opaque) {
+ struct loadparm_context *lp_ctx = talloc_get_type_abort(lp_opaque, struct loadparm_context);
+ schema->refresh_interval = lpcfg_parm_int(lp_ctx, NULL, "dsdb", "schema_reload_interval", schema->refresh_interval);
+ lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
+ struct loadparm_context);
+ schema->fsmo.update_allowed = lpcfg_parm_bool(lp_ctx, NULL,
+ "dsdb", "schema update allowed",
+ false);
+ }
+
schema->base_dn = talloc_steal(schema, schema_res->msgs[0]->dn);
prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
@@ -903,17 +916,6 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
schema->fsmo.we_are_master = false;
}
- lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
- struct loadparm_context);
- if (lp_ctx) {
- bool allowed = lpcfg_parm_bool(lp_ctx, NULL,
- "dsdb", "schema update allowed",
- false);
- schema->fsmo.update_allowed = allowed;
- } else {
- schema->fsmo.update_allowed = false;
- }
-
DEBUG(5, ("schema_fsmo_init: we are master[%s] updates allowed[%s]\n",
(schema->fsmo.we_are_master?"yes":"no"),
(schema->fsmo.update_allowed?"yes":"no")));