{
int index;
struct h_AddrHashChain *chain;
- char hoststr[16], hoststr2[16];
+ char hoststr[16];
/* hash into proper bucket */
index = h_HashIndex(addr);
- /* don't add the same entry multiple times */
+ /* don't add the same address:port pair entry multiple times */
for (chain = hostAddrHashTable[index]; chain; chain = chain->next) {
- if (chain->hostPtr == host) {
- if (chain->addr != addr || chain->port != port) {
- ViceLog(0,
- ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " exists as %s:%d when adding %s:%d\n",
- host, afs_inet_ntoa_r(chain->addr, hoststr),
- ntohs(chain->port), afs_inet_ntoa_r(addr, hoststr2),
- ntohs(port)));
- } else
- ViceLog(125,
- ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) already hashed\n",
- host, afs_inet_ntoa_r(chain->addr, hoststr),
- ntohs(chain->port)));
-
- return;
+ if (chain->addr == addr && chain->port == port) {
+ if (chain->hostPtr == host) {
+ ViceLog(125,
+ ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) already hashed\n",
+ host, afs_inet_ntoa_r(chain->addr, hoststr),
+ ntohs(chain->port)));
+ return;
+ }
+ if (!(chain->hostPtr->hostFlags & HOSTDELETED)) {
+ ViceLog(0,
+ ("h_AddHostToAddrHashTable_r: refusing to hash host %" AFS_PTR_FMT ", %"
+ AFS_PTR_FMT " (%s:%d) already hashed\n",
+ host, chain->hostPtr, afs_inet_ntoa_r(chain->addr, hoststr),
+ ntohs(chain->port)));
+ return;
+ }
}
}