diff options
author | Matthieu Patou <mat@matws.net> | 2012-05-30 10:43:27 -0700 |
---|---|---|
committer | Matthieu Patou <mat@matws.net> | 2012-06-22 23:22:04 -0700 |
commit | 6f3a8b41f5b43c35263a401b2bddbe4e49812b85 (patch) | |
tree | bd0da53909e07e60f2592c028cbacb28029b1320 /source4/dsdb | |
parent | 9f1213d954c72a46ac1f30e936e4004b1ed9ff76 (diff) | |
download | samba-6f3a8b41f5b43c35263a401b2bddbe4e49812b85.tar.gz samba-6f3a8b41f5b43c35263a401b2bddbe4e49812b85.tar.bz2 samba-6f3a8b41f5b43c35263a401b2bddbe4e49812b85.zip |
s4-dsdb: Add/Update SCHEMA_SEQ_NUM key in the metadata.tdb after schemaUpdateNow
The idea is to signal to other process accessing the database that the
schema was forced to be reloaded and so they should reload as well.
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/partition.c | 7 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/partition_metadata.c | 32 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/schema_load.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/samdb.h | 2 |
4 files changed, 43 insertions, 2 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index e4659a7f43..d4f020fc5e 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -1215,6 +1215,13 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req return ldb_next_request(module, req); } + if (strcmp(req->op.extended.oid, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID) == 0) { + /* Update the metadata.tdb to increment the schema version if needed*/ + DEBUG(10, ("Incrementing the sequence_number after schema_update_now\n")); + ret = partition_metadata_inc_schema_sequence(module); + return ldb_module_done(req, NULL, NULL, ret); + } + /* see if we are still up-to-date */ ret = partition_reload_if_required(module, data, req); if (ret != LDB_SUCCESS) { diff --git a/source4/dsdb/samdb/ldb_modules/partition_metadata.c b/source4/dsdb/samdb/ldb_modules/partition_metadata.c index 8e97b52802..0bf7a40640 100644 --- a/source4/dsdb/samdb/ldb_modules/partition_metadata.c +++ b/source4/dsdb/samdb/ldb_modules/partition_metadata.c @@ -139,6 +139,38 @@ static int partition_metadata_set_uint64(struct ldb_module *module, return LDB_SUCCESS; } +int partition_metadata_inc_schema_sequence(struct ldb_module *module) +{ + struct partition_private_data *data; + int ret; + uint64_t value; + + data = talloc_get_type_abort(ldb_module_get_private(module), + struct partition_private_data); + if (!data || !data->metadata) { + return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR, + "partition_metadata: metadata not initialized"); + } + + if (data->metadata->in_transaction == 0) { + return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR, + "partition_metadata: increment sequence number without transaction"); + } + ret = partition_metadata_get_uint64(module, DSDB_METADATA_SCHEMA_SEQ_NUM, &value, 0); + if (ret != LDB_SUCCESS) { + return ret; + } + + value++; + ret = partition_metadata_set_uint64(module, DSDB_METADATA_SCHEMA_SEQ_NUM, value, false); + if (ret == LDB_ERR_OPERATIONS_ERROR) { + /* Modify failed, let's try the add */ + ret = partition_metadata_set_uint64(module, DSDB_METADATA_SCHEMA_SEQ_NUM, value, true); + } + return ret; +} + + /* * Open sam.ldb.d/metadata.tdb. diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c index f922aabba9..9ae99a44b2 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_load.c +++ b/source4/dsdb/samdb/ldb_modules/schema_load.c @@ -363,8 +363,8 @@ static int schema_load_extended(struct ldb_module *module, struct ldb_request *r *lastts = 0; ldb_set_opaque(ldb, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME, lastts); - /* This is a no-op. We reload as soon as we can */ - return ldb_module_done(req, NULL, NULL, LDB_SUCCESS); + /* Pass to next module, the partition one should finish the chain */ + return ldb_next_request(module, req); } diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 73da3e20cf..3e2f4a2e79 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -218,4 +218,6 @@ struct dsdb_fsmo_extended_op { }; #define DSDB_ACL_CHECKS_DIRSYNC_FLAG 0x1 + +#define DSDB_METADATA_SCHEMA_SEQ_NUM "SCHEMA_SEQ_NUM" #endif /* __SAMDB_H__ */ |