diff options
author | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-01-05 15:29:16 -0500 |
---|---|---|
committer | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-17 22:34:40 -0500 |
commit | 49ff374f565b46d63678d1ea92eba436eacaa8cc (patch) | |
tree | 68ef33177f1d02ac76ace262e72d6ea2d9f0abe7 /server/realm.c | |
parent | 959c68d69e1887cb119f82bf0d64409936696fc0 (diff) |
Abstract realm server usability test
Whether a particular server is usable currently depends only on whether we
have successfully obtained its IP address. However, eventually it will also
depend on additional factors such as whether the server has been deleted from
the realm.list. To ease that transition, replace the 'usable' flag with a
'got_addr' flag (which is set when the address lookup succeeds), and add a
new function to test whether a server is usable.
Diffstat (limited to 'server/realm.c')
-rw-r--r-- | server/realm.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/server/realm.c b/server/realm.c index d4eeff6..60b2783 100644 --- a/server/realm.c +++ b/server/realm.c @@ -77,6 +77,12 @@ static int ticket_lookup(char *realm); #endif static int +is_usable(ZRealm_server *srvr) +{ + return srvr->got_addr; +} + +static int realm_get_idx_by_addr(ZRealm *realm, struct sockaddr_in *who) { @@ -85,7 +91,7 @@ realm_get_idx_by_addr(ZRealm *realm, /* loop through the realms */ for (srvr = realm->srvrs, b = 0; b < realm->count; b++, srvr++) { - if (!srvr->usable) + if (!is_usable(srvr)) continue; if (srvr->addr.sin_addr.s_addr == who->sin_addr.s_addr) return(b); @@ -107,7 +113,7 @@ realm_next_idx_by_idx(realm, idx) while (a > 0) { a--; srvr++; } for (srvr, b = idx; b < realm->count; b++, srvr++) { - if (!srvr->usable) + if (!is_usable(srvr)) continue; if (!srvr->dontsend) return(b); @@ -116,7 +122,7 @@ realm_next_idx_by_idx(realm, idx) /* recycle */ if (idx != 0) for (srvr = realm->srvrs, b = 0; b < idx; b++, srvr++) { - if (!srvr->usable) + if (!is_usable(srvr)) continue; if (!srvr->dontsend) return(b); @@ -335,7 +341,7 @@ realm_which_realm(struct sockaddr_in *who) for (srvr = otherrealms[a]->srvrs, b = 0; b < otherrealms[a]->count; b++, srvr++) { - if (!srvr->usable) + if (!is_usable(srvr)) continue; if (srvr->addr.sin_addr.s_addr == who->sin_addr.s_addr) return(otherrealms[a]); @@ -586,7 +592,7 @@ realm_init(void) /* use the server port */ srvr->addr.sin_port = srv_addr.sin_port; srvr->addr.sin_family = AF_INET; - srvr->usable = 1; + srvr->got_addr = 1; } else syslog(LOG_WARNING, "hostname failed, %s", srvr->name->string); } |