From 3957abea2abcd791e97e66be3f3ef211672ce713 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 30 Sep 2015 13:23:36 -0400 Subject: [PATCH] Windows: multi ping do not leak ping count In cm_CheckServersMulti() if cm_ConnByServer() fails or if cm_noIPAddr is zero then a cm_server.pingCount will be leaked. This can result in servers being marked down and never restored to an up state. This change adds the necessary pingCount decrement and moves the assignment of the cm_server_t pointer to serversp[] to make it clear that the cm_server_t will not be in the array if a failure occurs. Only objects in the array will have the pingCount decremented after the RPCs are issued. Change-Id: I18895c848039e4131a674d814019f236a1b0e5b5 Reviewed-on: http://gerrit.openafs.org/12048 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/cm_server.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/WINNT/afsd/cm_server.c b/src/WINNT/afsd/cm_server.c index 89e8c43406..8b327aa464 100644 --- a/src/WINNT/afsd/cm_server.c +++ b/src/WINNT/afsd/cm_server.c @@ -527,17 +527,17 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp) InterlockedIncrement(&tsp->pingCount); lock_ReleaseMutex(&tsp->mx); - serversp[nconns] = tsp; if (cm_noIPAddr > 0) code = cm_ConnByServer(tsp, cm_rootUserp, FALSE, &conns[nconns]); else code = RX_CALL_DEAD; if (code) { - if (code == RX_CALL_DEAD) { - lock_ObtainMutex(&tsp->mx); + lock_ObtainMutex(&tsp->mx); + if (code == RX_CALL_DEAD) cm_MarkServerDown(tsp, code, isDown); - lock_ReleaseMutex(&tsp->mx); - } + InterlockedDecrement(&tsp->pingCount); + lock_ReleaseMutex(&tsp->mx); + lock_ObtainRead(&cm_serverLock); cm_PutServerNoLock(tsp); continue; @@ -546,7 +546,7 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp) rxconns[nconns] = cm_GetRxConn(conns[nconns]); if (conntimer[nconns] = (isDown ? 1 : 0)) rx_SetConnHardDeadTime(rxconns[nconns], 10); - + serversp[nconns] = tsp; nconns++; } lock_ReleaseRead(&cm_serverLock); @@ -669,17 +669,17 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp) InterlockedIncrement(&tsp->pingCount); lock_ReleaseMutex(&tsp->mx); - serversp[nconns] = tsp; if (cm_noIPAddr > 0) code = cm_ConnByServer(tsp, cm_rootUserp, FALSE, &conns[nconns]); else code = RX_CALL_DEAD; if (code) { - if (code == RX_CALL_DEAD) { - lock_ObtainMutex(&tsp->mx); + lock_ObtainMutex(&tsp->mx); + if (code == RX_CALL_DEAD) cm_MarkServerDown(tsp, code, isDown); - lock_ReleaseMutex(&tsp->mx); - } + InterlockedDecrement(&tsp->pingCount); + lock_ReleaseMutex(&tsp->mx); + lock_ObtainRead(&cm_serverLock); cm_PutServerNoLock(tsp); continue; @@ -689,7 +689,7 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp) conntimer[nconns] = (isDown ? 1 : 0); if (isDown) rx_SetConnHardDeadTime(rxconns[nconns], 10); - + serversp[nconns] = tsp; nconns++; } lock_ReleaseRead(&cm_serverLock);