From efea50efda58be66638e5d38c8e57fdf9992f204 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 20 Jul 2012 12:36:43 -0400 Subject: Change refreshing of subdomains This patch keeps a local copy of the subdomains in the ipa subdomains plugin context. This has 2 advantages: 1. allows to check if anything changed w/o always hitting the sysdb. 2. later will allows us to dump this information w/o having to retrieve it again. The timestamp also allows to avoid refreshing too often. --- src/db/sysdb.h | 3 ++- src/db/sysdb_subdomains.c | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/db') diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 0e2404c7..43ac61c2 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -371,7 +371,8 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name); errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb, - struct sysdb_subdom **subdomains); + int num_subdoms, + struct sysdb_subdom *subdoms); errno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c index 8f1df88b..8489041b 100644 --- a/src/db/sysdb_subdomains.c +++ b/src/db/sysdb_subdomains.c @@ -430,7 +430,8 @@ done: } errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb, - struct sysdb_subdom **subdomains) + int num_subdoms, + struct sysdb_subdom *subdoms) { int ret; int sret; @@ -475,9 +476,9 @@ errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb, * - if a subdomain already exists in sysdb, mark it for preservation * - if the subdomain doesn't exist in sysdb, create its bare structure */ - for (c = 0; subdomains[c] != NULL; c++) { + for (c = 0; c < num_subdoms; c++) { for (d = 0; d < cur_subdomains_count; d++) { - if (strcasecmp(subdomains[c]->name, + if (strcasecmp(subdoms[c].name, cur_subdomains[d]->name) == 0) { keep_subdomain[d] = true; /* sub-domain already in cache, nothing to do */ @@ -487,14 +488,14 @@ errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb, if (d == cur_subdomains_count) { DEBUG(SSSDBG_TRACE_FUNC, ("Adding sub-domain [%s].\n", - subdomains[c]->name)); - ret = sysdb_domain_create(sysdb, subdomains[c]->name); + subdoms[c].name)); + ret = sysdb_domain_create(sysdb, subdoms[c].name); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_domain_create failed.\n")); goto done; } - ret = sysdb_add_subdomain_attributes(sysdb, subdomains[c]); + ret = sysdb_add_subdomain_attributes(sysdb, &subdoms[c]); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_add_subdomain_attributes failed.\n")); -- cgit