summaryrefslogtreecommitdiff
path: root/server/realm.c
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2012-11-25 04:55:43 -0500
committerGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-17 22:34:40 -0500
commit6452eb4960a542328615730b6a11d24a1281a457 (patch)
tree8bf2ec76eac733deb4265168c493807381b0b6ec /server/realm.c
parent7bedcf8336a4f6fde6c7be6c1d4bb4e6ea7a28c2 (diff)
Introduce usable flag on other-realm servers
Introduce a new per-realm-server 'usable' flag, which indicates the entry has been fully initialized and can be used. Routines which select a server or attempt to find one based on its address should ignore servers on which the usable flag is not set. This will allow the introduction of features which require recording servers which are not yet usable, such as asynchronous server name resolution.
Diffstat (limited to 'server/realm.c')
-rw-r--r--server/realm.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/server/realm.c b/server/realm.c
index bda371b..431893e 100644
--- a/server/realm.c
+++ b/server/realm.c
@@ -83,9 +83,12 @@ realm_get_idx_by_addr(ZRealm *realm,
int b;
/* loop through the realms */
- for (srvr = realm->srvrs, b = 0; b < realm->count; b++, srvr++)
+ for (srvr = realm->srvrs, b = 0; b < realm->count; b++, srvr++) {
+ if (!srvr->usable)
+ continue;
if (srvr->addr.sin_addr.s_addr == who->sin_addr.s_addr)
return(b);
+ }
return 0;
}
@@ -102,15 +105,21 @@ realm_next_idx_by_idx(realm, idx)
srvr = realm->srvrs; a = idx;
while (a > 0) { a--; srvr++; }
- for (srvr, b = idx; b < realm->count; b++, srvr++)
+ for (srvr, b = idx; b < realm->count; b++, srvr++) {
+ if (!srvr->usable)
+ continue;
if (!srvr->dontsend)
return(b);
+ }
/* recycle */
if (idx != 0)
- for (srvr = realm->srvrs, b = 0; b < idx; b++, srvr++)
+ for (srvr = realm->srvrs, b = 0; b < idx; b++, srvr++) {
+ if (!srvr->usable)
+ continue;
if (!srvr->dontsend)
- return(b);
+ return(b);
+ }
return 0;
}
@@ -315,9 +324,12 @@ realm_which_realm(struct sockaddr_in *who)
/* loop through the realms */
for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
/* loop through the addresses for the realm */
- for (srvr = realm->srvrs, b = 0; b < realm->count; b++, srvr++)
+ for (srvr = realm->srvrs, b = 0; b < realm->count; b++, srvr++) {
+ if (!srvr->usable)
+ continue;
if (srvr->addr.sin_addr.s_addr == who->sin_addr.s_addr)
return(realm);
+ }
return 0;
}
@@ -550,6 +562,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->dontsend = nosend[jj];
}
client = (Client *) malloc(sizeof(Client));