From d914034d4c5fd48fb89b1380da24984a520bae33 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 31 Oct 2012 09:52:23 -0400 Subject: [PATCH] Windows: use cm_GetVolume / cm_PutVolume Instead of locally incrementing and decrementing the cm_volume refCount field use cm_GetVolume and cm_PutVolume. Doing so makes it easier to see if there is an imbalance. Change-Id: Id62e42a74a9b1d9865a00dae177550a93e6e0f08 Reviewed-on: http://gerrit.openafs.org/8345 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_volume.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index 644d07a31d..7f682b0ce2 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -1229,7 +1229,7 @@ void cm_RefreshVolumes(int lifetime) */ lock_ObtainRead(&cm_volumeLock); for (volp = cm_data.allVolumesp; volp; volp=volp->allNextp) { - InterlockedIncrement(&volp->refCount); + cm_GetVolume(volp); lock_ReleaseRead(&cm_volumeLock); if (!(volp->flags & CM_VOLUMEFLAG_RESET) || @@ -1254,8 +1254,7 @@ void cm_RefreshVolumes(int lifetime) } lock_ObtainRead(&cm_volumeLock); - refCount = InterlockedDecrement(&volp->refCount); - osi_assertx(refCount >= 0, "cm_volume_t refCount underflow"); + cm_PutVolume(volp); } lock_ReleaseRead(&cm_volumeLock); } @@ -1424,12 +1423,11 @@ void cm_CheckOfflineVolumes(void) */ if ((volp->qflags & CM_VOLUME_QFLAG_IN_HASH) && !(volp->flags & CM_VOLUMEFLAG_NOEXIST)) { - InterlockedIncrement(&volp->refCount); + cm_GetVolume(volp); lock_ReleaseRead(&cm_volumeLock); cm_CheckOfflineVolume(volp, 0); lock_ObtainRead(&cm_volumeLock); - refCount = InterlockedDecrement(&volp->refCount); - osi_assertx(refCount >= 0, "cm_volume_t refCount underflow"); + cm_PutVolume(volp); } } lock_ReleaseRead(&cm_volumeLock); @@ -1554,7 +1552,7 @@ void cm_ChangeRankVolume(cm_server_t *tsp) for(volp = cm_data.allVolumesp; volp; volp=volp->allNextp) { code = 1 ; /* assume that list is unchanged */ - InterlockedIncrement(&volp->refCount); + cm_GetVolume(volp); lock_ReleaseRead(&cm_volumeLock); lock_ObtainWrite(&volp->rw); @@ -1567,8 +1565,7 @@ void cm_ChangeRankVolume(cm_server_t *tsp) lock_ReleaseWrite(&volp->rw); lock_ObtainRead(&cm_volumeLock); - refCount = InterlockedDecrement(&volp->refCount); - osi_assertx(refCount >= 0, "cm_volume_t refCount underflow"); + cm_PutVolume(volp); } lock_ReleaseRead(&cm_volumeLock); }