Windows: use port when finding server by address

Modify cm_FindServerByIP to search by port as well.

LICENSE MIT

Reviewed-on: http://gerrit.openafs.org/607
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2009-10-08 08:59:15 -04:00 committed by Jeffrey Altman
parent 8788462b65
commit dc94d7da5f
3 changed files with 9 additions and 8 deletions

View File

@ -354,7 +354,7 @@ SRXAFSCB_CallBack(struct rx_call *callp, AFSCBFids *fidsArrayp, AFSCBs *cbsArray
host = rx_HostOf(peerp);
port = rx_PortOf(peerp);
tsp = cm_FindServerByIP(host, CM_SERVER_FILE);
tsp = cm_FindServerByIP(host, port, CM_SERVER_FILE);
if (tsp) {
cellp = tsp->cellp;
cm_PutServer(tsp);
@ -980,7 +980,7 @@ SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
tsp = cm_FindServerByUuid(serverUuid, CM_SERVER_FILE);
}
if (!tsp)
tsp = cm_FindServerByIP(host, CM_SERVER_FILE);
tsp = cm_FindServerByIP(host, port, CM_SERVER_FILE);
if (tsp) {
cellp = tsp->cellp;
cm_PutServer(tsp);

View File

@ -921,14 +921,15 @@ cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cell
}
cm_server_t *
cm_FindServerByIP(afs_uint32 ipaddr, int type)
cm_FindServerByIP(afs_uint32 ipaddr, unsigned short port, int type)
{
cm_server_t *tsp;
lock_ObtainRead(&cm_serverLock);
for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
if (tsp->type == type &&
tsp->addr.sin_addr.S_un.S_addr == ipaddr)
tsp->addr.sin_addr.S_un.S_addr == ipaddr &&
(tsp->addr.sin_port == port || tsp->addr.sin_port == 0))
break;
}
@ -1361,9 +1362,9 @@ int cm_DumpServers(FILE *outputFile, char *cookie, int lock)
down = ctime(&tsp->downTime);
down[strlen(down)-1] = '\0';
sprintf(output, "%s - tsp=0x%p cell=%s addr=%-15s uuid=%s type=%s caps=0x%x flags=0x%x waitCount=%u rank=%u downTime=\"%s\" refCount=%u\r\n",
cookie, tsp, tsp->cellp ? tsp->cellp->name : "", hoststr, uuidstr, type,
tsp->capabilities, tsp->flags, tsp->waitCount, tsp->ipRank,
sprintf(output, "%s - tsp=0x%p cell=%s addr=%-15s port=%u uuid=%s type=%s caps=0x%x flags=0x%x waitCount=%u rank=%u downTime=\"%s\" refCount=%u\r\n",
cookie, tsp, tsp->cellp ? tsp->cellp->name : "", tsp->addr.sin_port, hoststr, uuidstr, type,
tsp->capabilities, tsp->flags, tsp->waitCount, tsp->ipRank,
(tsp->flags & CM_SERVERFLAG_DOWN) ? down : "up",
tsp->refCount);
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);

View File

@ -126,7 +126,7 @@ extern void cm_SetServerNo64Bit(cm_server_t * serverp, int no64bit);
extern void cm_SetServerNoInlineBulk(cm_server_t * serverp, int no);
extern cm_server_t * cm_FindServerByIP(afs_uint32 addr, int type);
extern cm_server_t * cm_FindServerByIP(afs_uint32 addr, unsigned short port, int type);
extern cm_server_t * cm_FindServerByUuid(afsUUID* uuid, int type);