X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fafs%2Fafs_cell.c;h=1061d3d6a6e36fbdc2f0cdd24d287662e6f13183;hp=7416249d9fa0b5cda229a72649c16121e4218414;hb=cb99519f776c33703e571aa2976250b203f15f06;hpb=b2821b103c5f4b2a3eb125bc36096580ce244e9e diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index 7416249..1061d3d 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -347,28 +347,46 @@ struct cell *afs_GetCellByName(acellName, locktype) } /*afs_GetCellByName*/ - struct cell *afs_GetCell(acell, locktype) register afs_int32 acell; afs_int32 locktype; { + return afs_GetCellInternal(acell, locktype, 1); +} + +/* This is only to be called if the caller is already holding afs_xcell */ +struct cell *afs_GetCellNoLock(acell, locktype) + register afs_int32 acell; + afs_int32 locktype; +{ + return afs_GetCellInternal(acell, locktype, 0); +} + +static struct cell *afs_GetCellInternal(acell, locktype, holdxcell) + register afs_int32 acell; + afs_int32 locktype; + int holdxcell; +{ register struct cell *tc; register struct afs_q *cq, *tq; AFS_STATCNT(afs_GetCell); if (acell == 1 && afs_rootcell) return afs_rootcell; - ObtainWriteLock(&afs_xcell,101); + if (holdxcell) + ObtainWriteLock(&afs_xcell,101); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tc = QTOC(cq); tq = QNext(cq); if (tc->cell == acell) { QRemove(&tc->lruq); QAdd(&CellLRU, &tc->lruq); - ReleaseWriteLock(&afs_xcell); + if (holdxcell) + ReleaseWriteLock(&afs_xcell); afs_RefreshCell(tc); return tc; } } - ReleaseWriteLock(&afs_xcell); + if (holdxcell) + ReleaseWriteLock(&afs_xcell); return (struct cell *) 0; } /*afs_GetCell*/