From 9059151dbb4dbda7f7d4f1a96a7d0b8db5756a0a Mon Sep 17 00:00:00 2001 From: venaas Date: Tue, 30 Sep 2008 11:47:41 +0000 Subject: improved findserver a bit git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@411 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- radsecproxy.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/radsecproxy.c b/radsecproxy.c index e140a38..533bf90 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -1704,22 +1704,20 @@ struct clsrvconf *choosesrvconf(struct list *srvconfs) { struct server *findserver(struct realm **realm, struct tlv *username, uint8_t acc) { struct clsrvconf *srvconf; struct realm *subrealm; + struct server *server = NULL; char *id = (char *)tlv2str(username); if (!id) return NULL; /* returns with lock on realm */ *realm = id2realm(realms, id); - if (!*realm) { - free(id); - return NULL; - } + if (!*realm) + goto exit; debug(DBG_DBG, "found matching realm: %s", (*realm)->name); srvconf = choosesrvconf(acc ? (*realm)->accsrvconfs : (*realm)->srvconfs); - if (!srvconf) { - free(id); - return NULL; - } + if (!srvconf) + goto exit; + server = srvconf->servers; if (!acc && !(*realm)->parent && !srvconf->servers) { subrealm = adddynamicrealmserver(*realm, srvconf, id); if (subrealm) { @@ -1727,10 +1725,12 @@ struct server *findserver(struct realm **realm, struct tlv *username, uint8_t ac pthread_mutex_unlock(&(*realm)->mutex); freerealm(*realm); *realm = subrealm; + server = ((struct clsrvconf *)subrealm->srvconfs->first->data)->servers; } } + exit: free(id); - return srvconf->servers; + return server; } -- cgit v1.1