From: Derrick Brashear Date: Thu, 31 Dec 2009 12:50:56 +0000 (-0500) Subject: viced host always hash on add X-Git-Tag: openafs-stable-1_4_12pre1~3 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=791fe698980ccd66088115e7147788f1029b5d71;p=packages%2Fo%2Fopenafs.git viced host always hash on add 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 Reviewed-by: Andrew Deason Reviewed-by: Alistair Ferguson Tested-by: Alistair Ferguson Reviewed-by: Michael Meffie Tested-by: Michael Meffie Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/viced/host.c b/src/viced/host.c index 60d1a6cbe..4c5dfab0e 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -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;