From bba1a5fd62cffcae076d1351df5a83fbc4a6ec17 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Jan 2013 20:30:04 -0500 Subject: Change the way domains are linked. - Use a double-linked list for domains and subdomains. - Never remove a subdomain, simply mark it as disabled if it becomes unused. - Rework the way subdomains are refreshed. Now sysdb_update_subdomains() actually updates the current subdomains and marks as disabled the ones not found in the sysdb or add new ones found. It never removes them. Removal of missing domains from sysdb is deferred to the providers, which will perform it at refresh time, for the ipa provider that is done by ipa_subdomains_write_mappings() now. sysdb_update_subdomains() is then used to update the memory hierarchy of the subdomains. - Removes sysdb_get_subdomains() - Removes copy_subdomain() - Add sysdb_subdomain_delete() --- src/responder/common/responder_common.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'src/responder/common/responder_common.c') diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 3a634e03..877181f8 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -886,41 +886,32 @@ int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain, struct sss_domain_info * responder_get_domain(TALLOC_CTX *sd_mem_ctx, struct resp_ctx *rctx, - const char *domain) + const char *name) { time_t now = time(NULL); time_t time_diff; struct sss_domain_info *dom; struct sss_domain_info *ret_dom = NULL; - int i; - for (dom = rctx->domains; dom; dom = get_next_domain(dom, false)) { - if (strcasecmp(dom->name, domain) == 0 || + for (dom = rctx->domains; dom; dom = get_next_domain(dom, true)) { + if (!dom->parent) { + time_diff = now - dom->subdomains_last_checked.tv_sec; + } + if (strcasecmp(dom->name, name) == 0 || (dom->flat_name != NULL && - strcasecmp(dom->flat_name, domain) == 0)) { + strcasecmp(dom->flat_name, name) == 0)) { ret_dom = dom; - break; - } - - for (i = 0; i < dom->subdomain_count; i++) { - if (strcasecmp(dom->subdomains[i]->name, domain) == 0 || - (dom->subdomains[i]->flat_name != NULL && - strcasecmp(dom->subdomains[i]->flat_name, domain) == 0)) { - /* Sub-domains may come and go, so we better copy the struct - * for each request. */ - ret_dom = copy_subdomain(sd_mem_ctx, dom->subdomains[i]); + if (!dom->parent || + (dom->parent && time_diff < rctx->domains_timeout)) { break; } } - time_diff = now - dom->subdomains_last_checked.tv_sec; - if (i < dom->subdomain_count && time_diff < rctx->domains_timeout) break; } - /* FIXME: we might want to return a real error, e.g. if copy_subdomain - * fails. */ + if (!ret_dom) { DEBUG(SSSDBG_OP_FAILURE, ("Unknown domain [%s], checking for" - "possible subdomains!\n", domain)); + "possible subdomains!\n", name)); } return ret_dom; -- cgit