]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-track-lock-tid-20061002
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Oct 2006 03:48:23 +0000 (03:48 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Oct 2006 03:48:23 +0000 (03:48 +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 ca740544c2bb45de30b752a1eee0b7c78acf6fa6..fff810df8b4144bad2f0e42d01c316387c75afd4 100644 (file)
@@ -56,6 +56,8 @@ void lock_ObtainWrite(osi_rwlock_t *lockp)
                lockp->flags |= OSI_LOCKFLAG_EXCL;
        }
 
+        lockp->tid = thrd_Current();
+
        LeaveCriticalSection(csp);
 }
 
@@ -85,7 +87,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)
@@ -132,6 +135,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);
@@ -163,6 +168,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);
        }
@@ -283,7 +290,10 @@ int lock_TryWrite(struct osi_rwlock *lockp)
                i = 1;
        }
 
-       LeaveCriticalSection(csp);
+       if (i)
+           lockp->tid = thrd_Current();
+
+        LeaveCriticalSection(csp);
 
        return i;
 }
@@ -311,6 +321,9 @@ int lock_TryMutex(struct osi_mutex *lockp) {
                i = 1;
        }
 
+        if (i)
+           lockp->tid = thrd_Current();
+
        LeaveCriticalSection(csp);
 
        return i;
@@ -452,6 +465,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 f5482b472c87bd2b71860bbc824adb88e1a29d8e..633ee84c9e1c85b7170f573972e21d2e479953c8 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 */