From: Jeffrey Altman Date: Tue, 14 Mar 2006 00:33:46 +0000 (+0000) Subject: STABLE14-viced-unspecified-host-hash-port-20060313 X-Git-Tag: openafs-stable-1_4_1-rc10~7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=8f3883282a9ecd680d8418da4f336f95aaa2dcbc;p=packages%2Fo%2Fopenafs.git STABLE14-viced-unspecified-host-hash-port-20060313 h_Alloc_r was not specifying the port for the newly allocated host when adding the host to the hash table. Use hashInsert_r instead so mistakes like this won't happen in the future. (cherry picked from commit a8b82b1a744859a3ce2796fd17f997e0bdd2b570) --- diff --git a/src/viced/host.c b/src/viced/host.c index 01dedb7aa..216ee83d6 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -450,7 +450,7 @@ h_gethostcps_r(register struct host *host, register afs_int32 now) slept ? (host->cpsCall = FT_ApproxTime()) : (host->cpsCall = now); H_UNLOCK; - code = pr_GetHostCPS(htonl(host->host), &host->hcps); + code = pr_GetHostCPS(ntohl(host->host), &host->hcps); H_LOCK; if (code) { /* @@ -504,7 +504,7 @@ h_gethostcps_r(register struct host *host, register afs_int32 now) /* args in net byte order */ void -h_flushhostcps(register afs_uint32 hostaddr, register afs_uint32 hport) +h_flushhostcps(register afs_uint32 hostaddr, register afs_uint16 hport) { register struct host *host; int held = 0; @@ -531,29 +531,20 @@ struct host * h_Alloc_r(register struct rx_connection *r_con) { struct servent *serverentry; - register index = h_HashIndex(rxr_HostOf(r_con)); register struct host *host; static struct rx_securityClass *sc = 0; afs_int32 now; - struct h_hashChain *h_hashChain; #if FS_STATS_DETAILED afs_uint32 newHostAddr_HBO; /*New host IP addr, in host byte order */ #endif /* FS_STATS_DETAILED */ host = GetHT(); - h_hashChain = (struct h_hashChain *)malloc(sizeof(struct h_hashChain)); - if (!h_hashChain) { - ViceLog(0, ("Failed malloc in h_Alloc_r\n")); - assert(0); - } - h_hashChain->hostPtr = host; - h_hashChain->addr = rxr_HostOf(r_con); - h_hashChain->next = hostHashTable[index]; - hostHashTable[index] = h_hashChain; - host->host = rxr_HostOf(r_con); host->port = rxr_PortOf(r_con); + + hashInsert_r(host->host, host->port, host); + if (consolePort == 0) { /* find the portal number for console */ #if defined(AFS_OSF_ENV) serverentry = getservbyname("ropcons", ""); @@ -609,7 +600,7 @@ h_Alloc_r(register struct rx_connection *r_con) /* Note: host should be released by caller if 0 == *heldp and non-null */ /* hostaddr and hport are in network order */ struct host * -h_Lookup_r(afs_uint32 haddr, afs_uint32 hport, int *heldp) +h_Lookup_r(afs_uint32 haddr, afs_uint16 hport, int *heldp) { register afs_int32 now; register struct host *host = 0; diff --git a/src/viced/host.h b/src/viced/host.h index 417e43be6..ec547bfb0 100644 --- a/src/viced/host.h +++ b/src/viced/host.h @@ -200,8 +200,10 @@ extern int h_Lock_r(register struct host *host); extern int DeleteAllCallBacks_r(struct host *host, int deletefe); extern struct host *h_Alloc(register struct rx_connection *r_con); extern struct host *h_Alloc_r(register struct rx_connection *r_con); -extern struct host *h_Lookup_r(afs_uint32 hostaddr, afs_uint32 hport, +extern struct host *h_Lookup_r(afs_uint32 hostaddr, afs_uint16 hport, int *heldp); +extern void hashInsert_r(afs_uint32 addr, afs_uint16 port, + struct host* host); extern struct host *h_LookupUuid_r(afsUUID * uuidp); extern int h_FreeConnection(struct rx_connection *tcon); extern void h_Enumerate(int (*proc) (), char *param); @@ -215,7 +217,7 @@ extern void h_PrintStats(); extern void h_PrintClients(); extern void h_GetWorkStats(); extern void h_flushhostcps(register afs_uint32 hostaddr, - register afs_uint32 hport); + register afs_uint16 hport); struct Interface *MultiVerifyInterface_r(); struct host *(hosttableptrs[h_MAXHOSTTABLES]); /* Used by h_itoh */