branch update for HEAD-2003091401
[reactos.git] / ntoskrnl / ps / suspend.c
index 1b97343..e085e50 100644 (file)
@@ -110,10 +110,15 @@ PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
   Thread->Tcb.SuspendCount++;
   if (!Thread->Tcb.SuspendApc.Inserted)
     {
-      KeInsertQueueApc(&Thread->Tcb.SuspendApc,
-                      NULL,
-                      NULL,
-                      0);
+      if (!KeInsertQueueApc(&Thread->Tcb.SuspendApc,
+                           NULL,
+                           NULL,
+                           IO_NO_INCREMENT))
+       {
+         Thread->Tcb.SuspendCount--;
+         ExReleaseFastMutex(&SuspendMutex);
+         return(STATUS_THREAD_IS_TERMINATING);
+       }
     }
   ExReleaseFastMutex(&SuspendMutex);
   if (PreviousSuspendCount != NULL)