Release the dispatcher lock after KiUnblockThread.
[reactos.git] / reactos / ntoskrnl / ke / gate.c
index 6530667..1155d7d 100644 (file)
@@ -63,13 +63,12 @@ KeWaitForGate(PKGATE Gate,
         GateWaitBlock->Thread = CurrentThread;
 
         /* Set the Thread Wait Data */
-        CurrentThread->WaitReason = WaitReason;
-        CurrentThread->WaitMode = WaitMode;
         CurrentThread->WaitIrql = OldIrql;
         CurrentThread->GateObject = Gate;
 
         /* Insert into the Wait List */
-        InsertTailList(&Gate->Header.WaitListHead, &GateWaitBlock->WaitListEntry);
+        InsertTailList(&Gate->Header.WaitListHead,
+                       &GateWaitBlock->WaitListEntry);
 
         /* Handle Kernel Queues */
         if (CurrentThread->Queue)
@@ -78,12 +77,15 @@ KeWaitForGate(PKGATE Gate,
             KiWakeQueue(CurrentThread->Queue);
         }
 
-        /* Block the Thread */
-        DPRINT("Blocking the Thread: %x\n", CurrentThread);
-        KiBlockThread(&Status,
-                      CurrentThread->Alertable,
-                      WaitMode,
-                      WaitReason);
+        /* Setup the wait information */
+        CurrentThread->WaitMode = WaitMode;
+        CurrentThread->WaitReason = WaitReason;
+        CurrentThread->WaitTime = ((PLARGE_INTEGER)&KeTickCount)->LowPart;
+        CurrentThread->State = Waiting;
+
+        /* Find a new thread to run */
+        DPRINT("Swapping threads\n");
+        Status = KiSwapThread();
 
         /* Check if we were executing an APC */
         if (Status != STATUS_KERNEL_APC) return;
@@ -136,7 +138,6 @@ KeSignalGateBoostPriority(PKGATE Gate)
     /* Reschedule the Thread */
     DPRINT("Unblocking the Thread\n");
     KiUnblockThread(WaitThread, &WaitStatus, EVENT_INCREMENT);
-    return;
 
 quit:
     /* Release the Dispatcher Database Lock */