diff options
author | Andrew Bartlett <abartlet@samba.org> | 2016-05-27 10:22:15 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2016-06-06 12:25:14 +0200 |
commit | 4d26210806419ef5710f38d0fa478e9f52243484 (patch) | |
tree | ee86a02d62011f550c2a7ccab3cdff88715f024b /source4 | |
parent | ee80da56b96721170a3349531292827888e0c3e2 (diff) | |
download | samba-4d26210806419ef5710f38d0fa478e9f52243484.tar.gz |
dsdb: Cache our local invocation_id at the start of each request
This avoids fetching it over and over again
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Jun 6 12:25:14 CEST 2016 on sn-devel-144
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 4a927f02d29..6596d457de1 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -80,6 +80,7 @@ struct replmd_replicated_request { struct ldb_request *req; const struct dsdb_schema *schema; + struct GUID our_invocation_id; /* the controls we pass down */ struct ldb_control **controls; @@ -579,6 +580,7 @@ static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *modu { struct ldb_context *ldb; struct replmd_replicated_request *ac; + const struct GUID *our_invocation_id; ldb = ldb_module_get_ctx(module); @@ -596,8 +598,19 @@ static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *modu ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); + talloc_free(ac); + return NULL; + } + + /* get our invocationId */ + our_invocation_id = samdb_ntds_invocation_id(ldb); + if (!our_invocation_id) { + ldb_debug_set(ldb, LDB_DEBUG_FATAL, + "replmd_add: unable to find invocationId\n"); + talloc_free(ac); return NULL; } + ac->our_invocation_id = *our_invocation_id; return ac; } @@ -873,7 +886,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) struct GUID guid; struct replPropertyMetaDataBlob nmd; struct ldb_val nmd_value; - const struct GUID *our_invocation_id; /* * The use of a time_t here seems odd, but as the NTTIME @@ -947,15 +959,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) return ret; } - /* get our invocationId */ - our_invocation_id = samdb_ntds_invocation_id(ldb); - if (!our_invocation_id) { - ldb_debug_set(ldb, LDB_DEBUG_ERROR, - "replmd_add: unable to find invocationId\n"); - talloc_free(ac); - return LDB_ERR_OPERATIONS_ERROR; - } - /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { @@ -1034,7 +1037,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) } if (sa->linkID != 0 && functional_level > DS_DOMAIN_FUNCTION_2000) { - ret = replmd_add_fix_la(module, e, ac->seq_num, our_invocation_id, t, &guid, sa, req); + ret = replmd_add_fix_la(module, e, ac->seq_num, &ac->our_invocation_id, t, &guid, sa, req); if (ret != LDB_SUCCESS) { talloc_free(ac); return ret; @@ -1069,7 +1072,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) } else { m->originating_change_time = now; } - m->originating_invocation_id = *our_invocation_id; + m->originating_invocation_id = ac->our_invocation_id; m->originating_usn = ac->seq_num; m->local_usn = ac->seq_num; ni++; @@ -4989,7 +4992,6 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a struct replUpToDateVectorBlob nuv; struct ldb_val nuv_value; struct ldb_message_element *nuv_el = NULL; - const struct GUID *our_invocation_id; struct ldb_message_element *orf_el = NULL; struct repsFromToBlob nrf; struct ldb_val *nrf_value = NULL; @@ -5063,20 +5065,12 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a ni++; } - /* get our invocation_id if we have one already attached to the ldb */ - our_invocation_id = samdb_ntds_invocation_id(ldb); - if (our_invocation_id == NULL) { - DEBUG(0, ("repl_meta_data: Could not find our own server's invocationID!\n")); - return replmd_replicated_request_werror(ar, WERR_DS_DRA_INTERNAL_ERROR); - } - /* merge in the source_dsa vector is available */ for (i=0; (ruv && i < ruv->count); i++) { found = false; - if (our_invocation_id && - GUID_equal(&ruv->cursors[i].source_dsa_invocation_id, - our_invocation_id)) { + if (GUID_equal(&ruv->cursors[i].source_dsa_invocation_id, + &ar->our_invocation_id)) { continue; } |