]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced host always hash on add
authorDerrick Brashear <shadow@dementia.org>
Thu, 31 Dec 2009 12:50:56 +0000 (07:50 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Thu, 7 Jan 2010 22:36:06 +0000 (14:36 -0800)
currently the openafs 1.4 code doesn't always add a host/port pair to the
hash when an interface address is being added. make the code match what exists
on the head

Change-Id: Ibf56a397b936abd1b0646c63c5dda88a59819538
Reviewed-on: http://gerrit.openafs.org/1053
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Tested-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/viced/host.c

index 60d1a6cbe1fa36c3024acb8692472fca8607b42c..4c5dfab0e43b7b7a656073fd3465e61c2a26e3c9 100644 (file)
@@ -1211,7 +1211,6 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
 {
     int i;
     int number;
-    int found;
     struct Interface *interface;
     char hoststr[16], hoststr2[16];
 
@@ -1223,35 +1222,41 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
      * for this host.
      */
     number = host->interface->numberOfInterfaces;
-    for (i = 0, found = 0; i < number && !found; i++) {
+    for (i = 0; i < number; i++) {
        if (host->interface->interface[i].addr == addr &&
             host->interface->interface[i].port == port) {
-           found = 1;
-            host->interface->interface[i].valid = 1;
+           ViceLog(125, ("addInterfaceAddr : host %x (%s:%d) addr %s:%d : found, valid: %d\n",
+                         host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),
+                         afs_inet_ntoa_r(addr, hoststr2), ntohs(port),
+                         host->interface->interface[i].valid));
+
+           if (host->interface->interface[i].valid == 0) {
+               hashInsert_r(addr, port, host);
+               host->interface->interface[i].valid = 1;
+           }
+           return 0;
         }
     }
 
-    ViceLog(125, ("addInterfaceAddr : host %x (%s:%d) addr %s:%d : found:%d\n", 
-                  host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), 
-                  afs_inet_ntoa_r(addr, hoststr2), ntohs(port), found));
+    ViceLog(125, ("addInterfaceAddr : host %x (%s:%d) addr %s:%d : not found, adding\n",
+                 host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),
+                 afs_inet_ntoa_r(addr, hoststr2), ntohs(port)));
     
-    if (!found) {
-       interface = (struct Interface *)
-           malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number));
-       if (!interface) {
-           ViceLog(0, ("Failed malloc in addInterfaceAddr_r\n"));
-           assert(0);
-       }
-       interface->numberOfInterfaces = number + 1;
-       interface->uuid = host->interface->uuid;
-       for (i = 0; i < number; i++)
-           interface->interface[i] = host->interface->interface[i];
-       interface->interface[number].addr = addr;
-       interface->interface[number].port = port;
-        interface->interface[number].valid = 1;
-       free(host->interface);
-       host->interface = interface;
+    interface = (struct Interface *)
+       malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number));
+    if (!interface) {
+       ViceLog(0, ("Failed malloc in addInterfaceAddr_r\n"));
+       assert(0);
     }
+    interface->numberOfInterfaces = number + 1;
+    interface->uuid = host->interface->uuid;
+    for (i = 0; i < number; i++)
+       interface->interface[i] = host->interface->interface[i];
+    interface->interface[number].addr = addr;
+    interface->interface[number].port = port;
+    interface->interface[number].valid = 1;
+    free(host->interface);
+    host->interface = interface;
 
     return 0;
 }
@@ -1905,7 +1910,6 @@ h_GetHost_r(struct rx_connection *tcon, int *heldp)
                                removeInterfaceAddr_r(oldHost, haddr, interface->interface[i].port);
                            }
                        }
-                        hashInsert_r(haddr, hport, oldHost);
                        oldHost->host = haddr;
                        oldHost->port = hport;
                        rxconn = oldHost->callback_rxcon;