mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Properly clean up terminated threads
svn path=/trunk/; revision=4633
This commit is contained in:
parent
8cbf35a0f7
commit
8eaabc5146
4 changed files with 34 additions and 10 deletions
|
@ -52,6 +52,11 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
|||
HalReturnToFirmware (FIRMWARE_OFF);
|
||||
#else
|
||||
PopSetSystemPowerState(PowerSystemShutdown);
|
||||
__asm__("cli\n");
|
||||
while (TRUE)
|
||||
{
|
||||
;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (Action == ShutdownReboot)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: reply.c,v 1.13 2003/04/26 23:13:32 hyperion Exp $
|
||||
/* $Id: reply.c,v 1.14 2003/05/01 22:00:31 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -220,7 +220,10 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
||||
if (STATUS_THREAD_IS_TERMINATING != Status)
|
||||
{
|
||||
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
||||
}
|
||||
ObDereferenceObject(Port);
|
||||
return(Status);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: kill.c,v 1.58 2002/11/27 20:54:37 hbirr Exp $
|
||||
/* $Id: kill.c,v 1.59 2003/05/01 22:00:31 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -159,7 +159,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
PKMUTANT Mutant;
|
||||
|
||||
CurrentThread = PsGetCurrentThread();
|
||||
|
||||
|
||||
DPRINT("terminating %x\n",CurrentThread);
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
|
||||
|
@ -188,6 +188,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
|
||||
DPRINT1("Unexpected return, CurrentThread %x PsGetCurrentThread() %x\n", CurrentThread, PsGetCurrentThread());
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
|
@ -224,6 +225,7 @@ PsTerminateOtherThread(PETHREAD Thread,
|
|||
*/
|
||||
{
|
||||
PKAPC Apc;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||
Thread, ExitStatus);
|
||||
|
@ -243,6 +245,12 @@ PsTerminateOtherThread(PETHREAD Thread,
|
|||
NULL,
|
||||
NULL,
|
||||
KernelMode);
|
||||
if (THREAD_STATE_BLOCKED == Thread->Tcb.State && UserMode == Thread->Tcb.WaitMode)
|
||||
{
|
||||
DPRINT("Unblocking thread\n");
|
||||
Status = STATUS_THREAD_IS_TERMINATING;
|
||||
PsUnblockThread(Thread, &Status);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: thread.c,v 1.110 2003/04/28 14:32:36 fireball Exp $
|
||||
/* $Id: thread.c,v 1.111 2003/05/01 22:00:31 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -71,9 +71,10 @@ HANDLE STDCALL PsGetCurrentThreadId(VOID)
|
|||
return(PsGetCurrentThread()->Cid.UniqueThread);
|
||||
}
|
||||
|
||||
VOID
|
||||
static VOID
|
||||
PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
||||
{
|
||||
assert(THREAD_STATE_READY == Thread->Tcb.State);
|
||||
if (Priority >= MAXIMUM_PRIORITY || Priority < 0)
|
||||
{
|
||||
DPRINT1("Invalid thread priority\n");
|
||||
|
@ -269,12 +270,19 @@ PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
|||
KIRQL oldIrql;
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
if (WaitStatus != NULL)
|
||||
if (THREAD_STATE_TERMINATED_1 != Thread->Tcb.State)
|
||||
{
|
||||
Thread->Tcb.WaitStatus = *WaitStatus;
|
||||
if (WaitStatus != NULL)
|
||||
{
|
||||
Thread->Tcb.WaitStatus = *WaitStatus;
|
||||
}
|
||||
Thread->Tcb.State = THREAD_STATE_READY;
|
||||
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Can't unblock thread 0x%08x because it's terminating\n", Thread);
|
||||
}
|
||||
Thread->Tcb.State = THREAD_STATE_READY;
|
||||
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue