DEVEL15-windows-server-find-by-uuid-20090614
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 19 Jun 2009 04:13:56 +0000 (04:13 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 19 Jun 2009 04:13:56 +0000 (04:13 +0000)
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.

(cherry picked from commit 88ef4fb720efd8f7c0b130b5bdf35ef840aafc59)

src/WINNT/afsd/cm_server.c
src/WINNT/afsd/cm_server.h

index a7aea33..68fa4b4 100644 (file)
@@ -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)
 {
index 61a7d8a..12f4207 100644 (file)
@@ -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);