diff options
author | Jeffrey Hutzelman <jhutz@cmu.edu> | 2012-11-25 04:55:43 -0500 |
---|---|---|
committer | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-17 22:34:40 -0500 |
commit | 6452eb4960a542328615730b6a11d24a1281a457 (patch) | |
tree | 8bf2ec76eac733deb4265168c493807381b0b6ec /server | |
parent | 7bedcf8336a4f6fde6c7be6c1d4bb4e6ea7a28c2 (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')
-rw-r--r-- | server/realm.c | 23 | ||||
-rw-r--r-- | server/zserver.h | 1 |
2 files changed, 19 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)); diff --git a/server/zserver.h b/server/zserver.h index 20c229d..b61cc06 100644 --- a/server/zserver.h +++ b/server/zserver.h @@ -113,6 +113,7 @@ struct _Destlist { struct _ZRealm_server { struct sockaddr_in addr; /* server's address */ + unsigned int usable :1; /* set once entry is usable */ unsigned int dontsend :1; /* private server, do not send */ }; |