]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-windows-track-lock-tid-20061002
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Oct 2006 03:46:38 +0000 (03:46 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Oct 2006 03:46:38 +0000 (03:46 +0000)
Keep track of the tid of the holding thread for writers

(cherry picked from commit b17a5d8192c08909ae57b540b25804ad9e1ae8a3)

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

index eca25bf066b1ad3c7a7dd73b77999d473f2258c3..36cb4022f0583d36c8d67a7f5dc3ea9c9e78e964 100644 (file)
@@ -55,6 +55,8 @@ void lock_ObtainWrite(osi_rwlock_t *lockp)
                lockp->flags |= OSI_LOCKFLAG_EXCL;
        }
 
+        lockp->tid = thrd_Current();
+
        LeaveCriticalSection(csp);
 }
 
@@ -83,7 +85,8 @@ void lock_ObtainRead(osi_rwlock_t *lockp)
                /* if we're here, all clear to set the lock */
                lockp->readers++;
        }
-       LeaveCriticalSection(csp);
+
+        LeaveCriticalSection(csp);
 }
 
 void lock_ReleaseRead(osi_rwlock_t *lockp)
@@ -128,6 +131,8 @@ void lock_ReleaseWrite(osi_rwlock_t *lockp)
 
        osi_assertx(lockp->flags & OSI_LOCKFLAG_EXCL, "write lock not held");
        
+        lockp->tid = 0;
+
        lockp->flags &= ~OSI_LOCKFLAG_EXCL;
        if (!osi_TEmpty(&lockp->d.turn)) {
                osi_TSignalForMLs(&lockp->d.turn, 0, csp);
@@ -158,6 +163,8 @@ void lock_ConvertWToR(osi_rwlock_t *lockp)
        lockp->flags &= ~OSI_LOCKFLAG_EXCL;
         lockp->readers++;
 
+        lockp->tid = 0;
+
        if (!osi_TEmpty(&lockp->d.turn)) {
                osi_TSignalForMLs(&lockp->d.turn, /* still have readers */ 1, csp);
        }
@@ -274,7 +281,10 @@ int lock_TryWrite(struct osi_rwlock *lockp)
                i = 1;
        }
 
-       LeaveCriticalSection(csp);
+       if (i)
+           lockp->tid = thrd_Current();
+
+        LeaveCriticalSection(csp);
 
        return i;
 }
@@ -301,6 +311,9 @@ int lock_TryMutex(struct osi_mutex *lockp) {
                i = 1;
        }
 
+        if (i)
+           lockp->tid = thrd_Current();
+
        LeaveCriticalSection(csp);
 
        return i;
@@ -435,6 +448,7 @@ void lock_InitializeRWLock(osi_rwlock_t *mp, char *namep)
        mp->flags = 0;
        mp->atomicIndex = osi_MUTEXHASH(mp);
        mp->readers = 0;
+        mp->tid = 0;
         osi_TInit(&mp->d.turn);
        return;
 }
index 7467f06e73dd479630b964c5c1a05655fdbfc209..b203c383158deee3d3fffa2a9e62950b1fbc4249 100644 (file)
@@ -56,6 +56,7 @@ typedef struct osi_rwlock {
        char type;                      /* for all types; type 0 uses atomic count */
        char flags;                     /* flags for base type */
         unsigned short atomicIndex;    /* index into hash table for low-level sync */
+        DWORD tid;                     /* writer's tid */
         unsigned short waiters;                /* waiters */
        unsigned short readers;         /* readers */
        union {
index e2dd99f4c3d3704ea3dd3430c4cc39d0b02e707b..3de16465cc05d57657131b68c3ad6e55cf24b678 100644 (file)
@@ -59,6 +59,7 @@ typedef struct osi_mutexStat {
        osi_turnstile_t turn;   /* the real turnstile */
        unsigned long refCount; /* so we can iterate cleanly */
        short states;
+        DWORD tid;
 
        /* track # of lock calls and blocks */
        LARGE_INTEGER lockedTime;       /* total time held */
@@ -81,6 +82,7 @@ typedef struct osi_rwlockStat {
        osi_turnstile_t turn;           /* the real turnstile */
        unsigned long refCount;         /* so we can iterate cleanly */
        short states;
+        DWORD tid;
 
        /* statistics */
        LARGE_INTEGER writeLockedTime;  /* total time held */