revert my changes Modified: trunk/reactos/ntoskrnl/ke/wait.c _____
Modified: trunk/reactos/ntoskrnl/ke/wait.c --- trunk/reactos/ntoskrnl/ke/wait.c 2005-03-22 23:34:08 UTC (rev 14274) +++ trunk/reactos/ntoskrnl/ke/wait.c 2005-03-23 13:26:38 UTC (rev 14275) @@ -250,7 +250,7 @@
/* It has a normal signal state, so unwait it and return */ KiSatisfyObjectWait(CurrentObject, CurrentThread); Status = STATUS_WAIT_0; - break; + goto WaitDone;
} else {
@@ -285,7 +285,7 @@
/* Return a timeout */ Status = STATUS_TIMEOUT; - break; + goto WaitDone; }
/* Point to Timer Wait Block and Thread Timer */ @@ -311,7 +311,7 @@
/* Return a timeout if we couldn't insert the timer for some reason */ Status = STATUS_TIMEOUT; - break; + goto WaitDone; } }
@@ -344,6 +344,7 @@
} while (TRUE);
+WaitDone: /* Release the Lock, we are done */ DPRINT("Returning from KeWaitForMultipleObjects(), %x. Status: %d\n", KeGetCurrentThread(), Status); KeReleaseDispatcherDatabaseLock(CurrentThread->WaitIrql); @@ -368,7 +369,7 @@ PKWAIT_BLOCK TimerWaitBlock; PKTIMER ThreadTimer; PKTHREAD CurrentThread = KeGetCurrentThread(); - BOOLEAN AllObjectsSignaled; + ULONG AllObjectsSignaled; ULONG WaitIndex; NTSTATUS Status; NTSTATUS WaitStatus; @@ -506,7 +507,7 @@ /* Satisfy their Waits and return to the caller */ KiSatisifyMultipleObjectWaits(WaitBlock); Status = STATUS_WAIT_0; - break; + goto WaitDone; }
/* Make sure we can satisfy the Alertable request */ @@ -523,7 +524,7 @@
/* Return a timeout */ Status = STATUS_TIMEOUT; - break; + goto WaitDone; }
/* Point to Timer Wait Block and Thread Timer */ @@ -548,20 +549,22 @@
/* Return a timeout if we couldn't insert the timer for some reason */ Status = STATUS_TIMEOUT; - break; + goto WaitDone; } }
/* Insert into Object's Wait List*/ - for (WaitBlock = CurrentThread->WaitBlockList; - WaitBlock != NULL; - WaitBlock = WaitBlock->NextWaitBlock) { + WaitBlock = CurrentThread->WaitBlockList; + while (WaitBlock) {
/* Get the Current Object */ CurrentObject = WaitBlock->Object;
/* Link the Object to this Wait Block */ InsertTailList(&CurrentObject->WaitListHead, &WaitBlock->WaitListEntry); + + /* Move to the next Wait Block */ + WaitBlock = WaitBlock->NextWaitBlock; }
/* Handle Kernel Queues */ @@ -657,10 +660,8 @@ /* Loop the Wait Entries */ DPRINT("KiWaitTest for Object: %x\n", Object); WaitList = &Object->WaitListHead; - - for (WaitEntry = WaitList->Flink; - (WaitEntry != WaitList) && (Object->SignalState > 0); - WaitEntry = WaitEntry->Flink) { + WaitEntry = WaitList->Flink; + while ((WaitEntry != WaitList) && (Object->SignalState > 0)) {
/* Get the current wait block */ CurrentWaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry); @@ -677,19 +678,21 @@
/* Everything must be satisfied */ DPRINT("Checking for a Wait All\n"); + NextWaitBlock = CurrentWaitBlock->NextWaitBlock;
/* Loop first to make sure they are valid */ - for (NextWaitBlock = CurrentWaitBlock->NextWaitBlock; - NextWaitBlock != NULL; - NextWaitBlock = NextWaitBlock->NextWaitBlock) { + while (NextWaitBlock) {
/* Check if the object is signaled */ if (!KiIsObjectSignaled(Object, CurrentWaitBlock->Thread)) {
/* It's not, move to the next one */ DPRINT1("One of the object is non-signaled, sorry.\n"); - continue; + goto SkipUnwait; } + + /* Go to the next Wait block */ + NextWaitBlock = NextWaitBlock->NextWaitBlock; }
/* All the objects are signaled, we can satisfy */ @@ -701,6 +704,10 @@ /* All waits satisfied, unwait the thread */ DPRINT("Unwaiting the Thread\n"); KiAbortWaitThread(CurrentWaitBlock->Thread, CurrentWaitBlock->WaitKey, Increment); + +SkipUnwait: + /* Next entry */ + WaitEntry = WaitEntry->Flink; }
DPRINT("Done\n"); @@ -721,14 +728,15 @@
/* Remove the Wait Blocks from the list */ DPRINT("Removing waits\n"); - - for (WaitBlock = Thread->WaitBlockList; - WaitBlock != NULL; - WaitBlock = WaitBlock->NextWaitBlock) { + WaitBlock = Thread->WaitBlockList; + while (WaitBlock) {
/* Remove it */ DPRINT("Removing Waitblock: %x, %x\n", WaitBlock, WaitBlock->NextWaitBlock); RemoveEntryList(&WaitBlock->WaitListEntry); + + /* Go to the next one */ + WaitBlock = WaitBlock->NextWaitBlock; };
/* Check if there's a Thread Timer */