mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[RTL] Do not mess with critical section lock when there is no reason to.
- When process is shutting down. - When the caller is so drunk that they leave twice the pub altough they entered it only once.
This commit is contained in:
parent
6d697561f0
commit
2486558ae1
1 changed files with 11 additions and 8 deletions
|
@ -114,12 +114,6 @@ RtlpWaitForCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
|||
EXCEPTION_RECORD ExceptionRecord;
|
||||
BOOLEAN LastChance = FALSE;
|
||||
|
||||
/* Do we have an Event yet? */
|
||||
if (!CriticalSection->LockSemaphore)
|
||||
{
|
||||
RtlpCreateCriticalSectionSem(CriticalSection);
|
||||
}
|
||||
|
||||
/* Increase the Debug Entry count */
|
||||
DPRINT("Waiting on Critical Section Event: %p %p\n",
|
||||
CriticalSection,
|
||||
|
@ -136,10 +130,15 @@ RtlpWaitForCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
|||
LdrpShutdownThreadId == NtCurrentTeb()->RealClientId.UniqueThread)
|
||||
{
|
||||
DPRINT("Forcing ownership of critical section %p\n", CriticalSection);
|
||||
CriticalSection->LockCount = 0;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Do we have an Event yet? */
|
||||
if (!CriticalSection->LockSemaphore)
|
||||
{
|
||||
RtlpCreateCriticalSectionSem(CriticalSection);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Increase the number of times we've had contention */
|
||||
|
@ -715,9 +714,13 @@ RtlLeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
|||
*/
|
||||
if (--CriticalSection->RecursionCount)
|
||||
{
|
||||
if (CriticalSection->RecursionCount < 0)
|
||||
{
|
||||
DPRINT1("CRITICAL SECTION MESS: Section %p is not acquired!\n", CriticalSection);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
/* Someone still owns us, but we are free. This needs to be done atomically. */
|
||||
InterlockedDecrement(&CriticalSection->LockCount);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue