From 4bf562265c18433868e3ae28c4b6fb3dd30d57af Mon Sep 17 00:00:00 2001 From: Tom Keiser Date: Sun, 3 Apr 2005 21:09:53 +0000 Subject: [PATCH] hid2client-write-lock-20050403 FIXES 17867 h_ID2Client currently returns a client struct with a shared lock. The only caller of h_ID2Client (SRXAFS_FlushCPS) immediately calls BoostSharedLock. This patch just goes ahead and makes h_ID2Client return it with the write lock so we don't enter the Lock struct mutex multiple times in a row. This also happens to remove the last reference to BoostSharedLock in the tree. --- src/viced/afsfileprocs.c | 3 +-- src/viced/host.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index e869dcbfe..fb3a071c7 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -6004,11 +6004,10 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids, for (i = 0; i < nids; i++, vd++) { if (!*vd) continue; - client = h_ID2Client(*vd); /* returns client locked, or NULL */ + client = h_ID2Client(*vd); /* returns client write locked, or NULL */ if (!client) continue; - BoostSharedLock(&client->lock); client->prfail = 2; /* Means re-eval client's cps */ #ifdef notdef if (client->tcon) { diff --git a/src/viced/host.c b/src/viced/host.c index 8193a6863..0c44c6394 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1328,7 +1328,7 @@ MapName_r(char *aname, char *acell, afs_int32 * aval) /*MapName*/ -/* NOTE: this returns the client with a Shared lock */ +/* NOTE: this returns the client with a Write lock */ struct client * h_ID2Client(afs_int32 vid) { @@ -1343,7 +1343,7 @@ h_ID2Client(afs_int32 vid) if (!client->deleted && client->ViceId == vid) { client->refCount++; H_UNLOCK; - ObtainSharedLock(&client->lock); + ObtainWriteLock(&client->lock); H_LOCK; client->refCount--; H_UNLOCK; @@ -1353,7 +1353,7 @@ h_ID2Client(afs_int32 vid) } H_UNLOCK; - return 0; + return NULL; } /* -- 2.39.5