]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-viced-unspecified-host-hash-port-20060313
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 14 Mar 2006 00:33:46 +0000 (00:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 14 Mar 2006 00:33:46 +0000 (00:33 +0000)
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)

src/viced/host.c
src/viced/host.h

index 01dedb7aa75589ff99c47f1f0c20fae6c4dc760c..216ee83d64d0fe79f8ebf074bc31a5a34e527c9e 100644 (file)
@@ -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;
index 417e43be6ebdd9e83fd255000621d69110a7a363..ec547bfb07141469a322c736a2b3a6bc86b682a4 100644 (file)
@@ -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 */