Windows: Clear peer RPC stats on IP addr change
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 20 Jul 2012 06:57:35 +0000 (02:57 -0400)
committerDerrick Brashear <shadow@dementix.org>
Sun, 22 Jul 2012 12:20:22 +0000 (05:20 -0700)
When an IP address change has been detected, clear the peer
RPC statistics used for server ranking.

Change-Id: Ie9e3f4553f9d0b22d4876b729ce0028e762efb33
Reviewed-on: http://gerrit.openafs.org/7826
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

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

index c93e4bf..d55d34f 100644 (file)
@@ -82,6 +82,8 @@ void * cm_IpAddrDaemon(void * vparm)
                 smb_SetLanAdapterChangeDetected();
             cm_SetLanAdapterChangeDetected();
             thrd_ResetEvent(cm_IPAddrDaemon_ShutdownEvent);
+
+            cm_ServerClearRPCStats();
        }
     }
 
index 6efb8e3..c66f14a 100644 (file)
@@ -50,6 +50,28 @@ cm_ForceNewConnectionsAllServers(void)
     lock_ReleaseRead(&cm_serverLock);
 }
 
+void
+cm_ServerClearRPCStats(void) {
+    cm_server_t *tsp;
+    afs_uint16 port;
+
+    lock_ObtainRead(&cm_serverLock);
+    for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
+        switch (tsp->type) {
+        case CM_SERVER_VLDB:
+           port = htons(7003);
+            rx_ClearPeerRPCStats(opcode_VL_ProbeServer>>32, tsp->addr.sin_addr.s_addr, port);
+           break;
+       case CM_SERVER_FILE:
+           port = htons(7000);
+            rx_ClearPeerRPCStats(opcode_RXAFS_GetCapabilities>>32, tsp->addr.sin_addr.s_addr, port);
+            rx_ClearPeerRPCStats(opcode_RXAFS_GetTime>>32, tsp->addr.sin_addr.s_addr, port);
+           break;
+        }
+    }
+    lock_ReleaseRead(&cm_serverLock);
+}
+
 /*
  * lock_ObtainMutex must be held prior to calling
  * this function.
index 8d13aef..fc82153 100644 (file)
@@ -157,6 +157,8 @@ extern int cm_ServerEqual(cm_server_t *srv1, cm_server_t *srv2);
 
 extern int cm_IsServerListEmpty(cm_serverRef_t *serversp);
 
+extern void cm_ServerClearRPCStats(void);
+
 /* Protected by cm_syscfgLock (rw) */
 extern int cm_noIPAddr;         /* number of client network interfaces */
 extern int cm_IPAddr[CM_MAXINTERFACE_ADDR];    /* client's IP address in host order */