Debug.Assert(lockID != 0);
ThreadLocalLockEntry? headEntry = t_lockEntryHead;
- if (headEntry != null)
+ if (headEntry != null && headEntry._lockID == lockID)
{
- if (headEntry._lockID == lockID)
- {
- VerifyNoNonemptyEntryInListAfter(lockID, headEntry);
- return headEntry;
- }
-
- if (headEntry.IsFree)
- {
- VerifyNoNonemptyEntryInListAfter(lockID, headEntry);
- headEntry._lockID = lockID;
- return headEntry;
- }
+ VerifyNoNonemptyEntryInListAfter(lockID, headEntry);
+ return headEntry;
}
return GetOrCreateCurrentSlow(lockID, headEntry);
trwl.Dispose();
}
+ [Fact]
+ public static void MultipleNestedReadersMiscellaneousTest()
+ {
+ var trwl1 = new TestReaderWriterLock();
+ var trwl2 = new TestReaderWriterLock();
+
+ trwl1.AcquireReaderLock();
+
+ trwl2.AcquireReaderLock();
+ trwl2.ReleaseReaderLock();
+
+ trwl1.AcquireReaderLock();
+ trwl1.ReleaseReaderLock();
+ trwl1.ReleaseReaderLock();
+
+ trwl1.Dispose();
+ trwl2.Dispose();
+ }
+
[Fact]
public static void DowngradeQuirks_ChangedInDotNetCore()
{