mirror of
https://github.com/reactos/reactos.git
synced 2024-07-02 10:45:24 +00:00
fix formatting
svn path=/trunk/; revision=41601
This commit is contained in:
parent
5d33bdc236
commit
d01aa9d736
|
@ -6,26 +6,26 @@ VOID RecursiveMutexInit( PRECURSIVE_MUTEX RecMutex ) {
|
|||
KeInitializeSpinLock( &RecMutex->SpinLock );
|
||||
ExInitializeFastMutex( &RecMutex->Mutex );
|
||||
KeInitializeEvent( &RecMutex->StateLockedEvent,
|
||||
NotificationEvent, FALSE );
|
||||
NotificationEvent, FALSE );
|
||||
}
|
||||
|
||||
/* NOTE: When we leave, the FAST_MUTEX must have been released. The result
|
||||
* is that we always exit in the same irql as entering */
|
||||
* is that we always exit in the same irql as entering */
|
||||
SIZE_T RecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOLEAN ToWrite ) {
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PVOID CurrentThread = KeGetCurrentThread();
|
||||
KIRQL CurrentIrql;
|
||||
|
||||
/* Wait for the previous user to unlock the RecMutex state. There might be
|
||||
* multiple waiters waiting to change the state. We need to check each
|
||||
* time we get the event whether somebody still has the state locked */
|
||||
* multiple waiters waiting to change the state. We need to check each
|
||||
* time we get the event whether somebody still has the state locked */
|
||||
|
||||
if( !RecMutex ) return FALSE;
|
||||
|
||||
if( CurrentThread == RecMutex->CurrentThread ||
|
||||
(!ToWrite && !RecMutex->Writer) ) {
|
||||
RecMutex->LockCount++;
|
||||
return TRUE;
|
||||
(!ToWrite && !RecMutex->Writer) ) {
|
||||
RecMutex->LockCount++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CurrentIrql = KeGetCurrentIrql();
|
||||
|
@ -33,29 +33,29 @@ SIZE_T RecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOLEAN ToWrite ) {
|
|||
ASSERT(CurrentIrql <= DISPATCH_LEVEL);
|
||||
|
||||
if( CurrentIrql <= APC_LEVEL ) {
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
RecMutex->OldIrql = CurrentIrql;
|
||||
while( RecMutex->Locked ) {
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
Status = KeWaitForSingleObject( &RecMutex->StateLockedEvent,
|
||||
UserRequest,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL );
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
}
|
||||
RecMutex->Locked = TRUE;
|
||||
RecMutex->Writer = ToWrite;
|
||||
RecMutex->CurrentThread = CurrentThread;
|
||||
RecMutex->LockCount++;
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
RecMutex->OldIrql = CurrentIrql;
|
||||
while( RecMutex->Locked ) {
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
Status = KeWaitForSingleObject( &RecMutex->StateLockedEvent,
|
||||
UserRequest,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL );
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
}
|
||||
RecMutex->Locked = TRUE;
|
||||
RecMutex->Writer = ToWrite;
|
||||
RecMutex->CurrentThread = CurrentThread;
|
||||
RecMutex->LockCount++;
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
} else {
|
||||
KeAcquireSpinLockAtDpcLevel( &RecMutex->SpinLock );
|
||||
KeAcquireSpinLockAtDpcLevel( &RecMutex->SpinLock );
|
||||
RecMutex->OldIrql = DISPATCH_LEVEL;
|
||||
RecMutex->Locked = TRUE;
|
||||
RecMutex->Writer = ToWrite;
|
||||
RecMutex->CurrentThread = CurrentThread;
|
||||
RecMutex->LockCount++;
|
||||
RecMutex->Locked = TRUE;
|
||||
RecMutex->Writer = ToWrite;
|
||||
RecMutex->CurrentThread = CurrentThread;
|
||||
RecMutex->LockCount++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -67,20 +67,20 @@ VOID RecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex ) {
|
|||
RecMutex->LockCount--;
|
||||
|
||||
if( !RecMutex->LockCount ) {
|
||||
RecMutex->CurrentThread = NULL;
|
||||
if( RecMutex->OldIrql <= APC_LEVEL ) {
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
RecMutex->Locked = FALSE;
|
||||
RecMutex->Writer = FALSE;
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
} else {
|
||||
RecMutex->Locked = FALSE;
|
||||
RecMutex->Writer = FALSE;
|
||||
KeReleaseSpinLockFromDpcLevel( &RecMutex->SpinLock );
|
||||
}
|
||||
RecMutex->CurrentThread = NULL;
|
||||
if( RecMutex->OldIrql <= APC_LEVEL ) {
|
||||
ExAcquireFastMutex( &RecMutex->Mutex );
|
||||
RecMutex->Locked = FALSE;
|
||||
RecMutex->Writer = FALSE;
|
||||
ExReleaseFastMutex( &RecMutex->Mutex );
|
||||
} else {
|
||||
RecMutex->Locked = FALSE;
|
||||
RecMutex->Writer = FALSE;
|
||||
KeReleaseSpinLockFromDpcLevel( &RecMutex->SpinLock );
|
||||
}
|
||||
|
||||
KePulseEvent( &RecMutex->StateLockedEvent, IO_NETWORK_INCREMENT,
|
||||
FALSE );
|
||||
KePulseEvent( &RecMutex->StateLockedEvent, IO_NETWORK_INCREMENT,
|
||||
FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue