- Use _SEH2_YIELD when returning from an exception instead of returning outside the...
[reactos.git] / reactos / ntoskrnl / ke / wait.c
index ac1ae64..2e9c1c8 100644 (file)
@@ -117,15 +117,15 @@ KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
                           NULL);
 }
 
-/* KiAcquireGuardedMutex depends on these bits being right */
-C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC);
-
 VOID
 FASTCALL
 KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
 {
     ULONG BitsToRemove, BitsToAdd;
     LONG OldValue, NewValue;
+
+    /* We depend on these bits being just right */
+    C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC);
     
     /* Increase the contention count */
     GuardedMutex->Contention++;
@@ -849,10 +849,10 @@ NtDelayExecution(IN BOOLEAN Alertable,
 {
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     LARGE_INTEGER SafeInterval;
-    NTSTATUS Status = STATUS_SUCCESS;
+    NTSTATUS Status;
 
     /* Check the previous mode */
-    if(PreviousMode != KernelMode)
+    if (PreviousMode != KernelMode)
     {
         /* Enter SEH for probing */
         _SEH2_TRY
@@ -863,11 +863,10 @@ NtDelayExecution(IN BOOLEAN Alertable,
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
-            /* Get SEH exception */
-            Status = _SEH2_GetExceptionCode();
+            /* Return the exception code */
+            _SEH2_YIELD(return _SEH2_GetExceptionCode());
         }
         _SEH2_END;
-        if (!NT_SUCCESS(Status)) return Status;
    }
 
    /* Call the Kernel Function */