From 88ef4fb720efd8f7c0b130b5bdf35ef840aafc59 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 15 Jun 2009 02:02:59 +0000 Subject: [PATCH] windows-server-find-by-uuid-20090614 LICENSE MIT Add cm_FindServerByUuid(). This function is similar to cm_FindServerByIP() but uses the server's known uuid instead which is constant across multi- homed systems. --- src/WINNT/afsd/cm_server.c | 20 ++++++++++++++++++++ src/WINNT/afsd/cm_server.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/WINNT/afsd/cm_server.c b/src/WINNT/afsd/cm_server.c index a7aea335de..68fa4b4e10 100644 --- a/src/WINNT/afsd/cm_server.c +++ b/src/WINNT/afsd/cm_server.c @@ -941,6 +941,26 @@ cm_FindServerByIP(afs_uint32 ipaddr, int type) return tsp; } +cm_server_t * +cm_FindServerByUuid(afsUUID *serverUuid, int type) +{ + cm_server_t *tsp; + + lock_ObtainRead(&cm_serverLock); + for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) { + if (tsp->type == type && !afs_uuid_equal(&tsp->uuid, serverUuid)) + break; + } + + /* bump ref count if we found the server */ + if (tsp) + cm_GetServerNoLock(tsp); + + lock_ReleaseRead(&cm_serverLock); + + return tsp; +} + /* find a server based on its properties */ cm_server_t *cm_FindServer(struct sockaddr_in *addrp, int type) { diff --git a/src/WINNT/afsd/cm_server.h b/src/WINNT/afsd/cm_server.h index 61a7d8a0e3..12f42077e3 100644 --- a/src/WINNT/afsd/cm_server.h +++ b/src/WINNT/afsd/cm_server.h @@ -128,6 +128,8 @@ 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_FindServerByUuid(afsUUID* uuid, int type); + extern void cm_SetLanAdapterChangeDetected(void); extern void cm_RemoveVolumeFromServer(cm_server_t * serverp, afs_uint32 volID);