git.samba.org
/
metze
/
samba
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8489934
)
s4:dsdb: cached results of samdb_rodc()
author
Stefan Metzmacher
<metze@samba.org>
Tue, 11 May 2010 08:34:19 +0000
(10:34 +0200)
committer
Stefan Metzmacher
<metze@samba.org>
Tue, 11 May 2010 08:34:19 +0000
(10:34 +0200)
metze
source4/dsdb/common/util.c
patch
|
blob
|
history
diff --git
a/source4/dsdb/common/util.c
b/source4/dsdb/common/util.c
index 5deb1d08b156c605f861d1f9bb42dec53c9a77f6..7c27b4adfb2f1e1557fdc4151b308c02033a1184 100644
(file)
--- a/
source4/dsdb/common/util.c
+++ b/
source4/dsdb/common/util.c
@@
-2705,11
+2705,39
@@
int samdb_is_rodc(struct ldb_context *sam_ctx, const struct GUID *objectGUID, bo
int samdb_rodc(struct ldb_context *sam_ctx, bool *am_rodc)
{
const struct GUID *objectGUID;
int samdb_rodc(struct ldb_context *sam_ctx, bool *am_rodc)
{
const struct GUID *objectGUID;
+ int ret;
+ bool *cached;
+
+ /* see if we have a cached copy */
+ cached = (bool *)ldb_get_opaque(ldb, "cache.am_rodc");
+ if (cached) {
+ *am_rodc = *cached;
+ return LDB_SUCCESS;
+ }
+
objectGUID = samdb_ntds_objectGUID(sam_ctx);
if (!objectGUID) {
return LDB_ERR_OPERATIONS_ERROR;
}
objectGUID = samdb_ntds_objectGUID(sam_ctx);
if (!objectGUID) {
return LDB_ERR_OPERATIONS_ERROR;
}
- return samdb_is_rodc(sam_ctx, objectGUID, am_rodc);
+
+ ret = samdb_is_rodc(sam_ctx, objectGUID, am_rodc);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ cached = talloc(ldb, bool);
+ if (cached == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ *cached = *am_rodc;
+
+ ret = ldb_set_opaque(ldb, "cache.am_rodc", cached);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(cached);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return LDB_SUCCESS;
}
}