]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-windows-add-tid-to-mutex-20050827
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 28 Aug 2005 04:33:24 +0000 (04:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 28 Aug 2005 04:33:24 +0000 (04:33 +0000)
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)

src/WINNT/client_osi/osibasel.c
src/WINNT/client_osi/osibasel.h

index 4b4dadd5c9b4dc4c4c94aac39c759f6fbeab4615..eca25bf066b1ad3c7a7dd73b77999d473f2258c3 100644 (file)
@@ -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;
index fc80df4c8ac744d78cf489c1382265b20f110bbc..7467f06e73dd479630b964c5c1a05655fdbfc209 100644 (file)
@@ -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 {