From: Jeffrey Altman Date: Sun, 28 Aug 2005 04:33:24 +0000 (+0000) Subject: STABLE14-windows-add-tid-to-mutex-20050827 X-Git-Tag: openafs-stable-1_4_0-rc2~5 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7c469ff6aa91a1f2ecdf41e08ace0325d61c94da;p=packages%2Fo%2Fopenafs.git STABLE14-windows-add-tid-to-mutex-20050827 Add to mutex objects the ID of the thread that holds the lock. This will make future debugging much easier. (cherry picked from commit c0fea634084ee1c223c611c3ab3955a13d1ba884) --- diff --git a/src/WINNT/client_osi/osibasel.c b/src/WINNT/client_osi/osibasel.c index 4b4dadd5c..eca25bf06 100644 --- a/src/WINNT/client_osi/osibasel.c +++ b/src/WINNT/client_osi/osibasel.c @@ -192,6 +192,7 @@ void lock_ObtainMutex(struct osi_mutex *lockp) /* if we're here, all clear to set the lock */ lockp->flags |= OSI_LOCKFLAG_EXCL; } + lockp->tid = thrd_Current(); LeaveCriticalSection(csp); } @@ -212,6 +213,7 @@ void lock_ReleaseMutex(struct osi_mutex *lockp) osi_assertx(lockp->flags & OSI_LOCKFLAG_EXCL, "mutex not held"); lockp->flags &= ~OSI_LOCKFLAG_EXCL; + lockp->tid = 0; if (!osi_TEmpty(&lockp->d.turn)) { osi_TSignalForMLs(&lockp->d.turn, 0, csp); } @@ -411,6 +413,7 @@ void lock_InitializeMutex(osi_mutex_t *mp, char *namep) */ mp->type = 0; mp->flags = 0; + mp->tid = 0; mp->atomicIndex = osi_MUTEXHASH(mp); osi_TInit(&mp->d.turn); return; diff --git a/src/WINNT/client_osi/osibasel.h b/src/WINNT/client_osi/osibasel.h index fc80df4c8..7467f06e7 100644 --- a/src/WINNT/client_osi/osibasel.h +++ b/src/WINNT/client_osi/osibasel.h @@ -31,6 +31,7 @@ typedef struct osi_mutex { char type; /* for all types; type 0 uses atomic count */ char flags; /* flags for base type */ unsigned short atomicIndex; /* index of lock for low-level sync */ + thread_t tid; /* tid of thread that owns the lock */ unsigned short waiters; /* waiters */ unsigned short pad; union {