From 4a8192367d14da53c1c4f055b513d13abe60c304 Mon Sep 17 00:00:00 2001 From: ghostclearsky <57634180+ghostclearsky@users.noreply.github.com> Date: Thu, 1 Jun 2023 11:12:19 +0800 Subject: [PATCH] Fix: Possible occurrence of write lock leakage during high concurrency --- .../Wintellect.Threading/ResourceLocks/ResourceLock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerThreading-Desktop/Wintellect.Threading/ResourceLocks/ResourceLock.cs b/PowerThreading-Desktop/Wintellect.Threading/ResourceLocks/ResourceLock.cs index 62b725b..e235c26 100644 --- a/PowerThreading-Desktop/Wintellect.Threading/ResourceLocks/ResourceLock.cs +++ b/PowerThreading-Desktop/Wintellect.Threading/ResourceLocks/ResourceLock.cs @@ -243,7 +243,6 @@ public void Leave() { #if DEADLOCK_DETECTION if (s_PerformDeadlockDetection) DeadlockDetector.ReleaseLock(this); #endif - OnLeave(exclusive); if (exclusive) { Interlocked.Add(ref m_readWriteCounts, -c_OneWriterCount); //if (AcquiringThreadMustRelease) Thread.EndCriticalRegion(); @@ -251,6 +250,7 @@ public void Leave() { Interlocked.Add(ref m_readWriteCounts, -c_OneReaderCount); // When done reading, there is no need to call EndCriticalRegion since resource was not modified } + OnLeave(exclusive); } #region Helper Methods