mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +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);
|
HalReturnToFirmware (FIRMWARE_OFF);
|
||||||
#else
|
#else
|
||||||
PopSetSystemPowerState(PowerSystemShutdown);
|
PopSetSystemPowerState(PowerSystemShutdown);
|
||||||
|
__asm__("cli\n");
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (Action == ShutdownReboot)
|
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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -219,8 +219,11 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
if (STATUS_THREAD_IS_TERMINATING != Status)
|
||||||
{
|
{
|
||||||
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
||||||
|
}
|
||||||
ObDereferenceObject(Port);
|
ObDereferenceObject(Port);
|
||||||
return(Status);
|
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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -188,6 +188,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
|
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
|
||||||
|
DPRINT1("Unexpected return, CurrentThread %x PsGetCurrentThread() %x\n", CurrentThread, PsGetCurrentThread());
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +225,7 @@ PsTerminateOtherThread(PETHREAD Thread,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PKAPC Apc;
|
PKAPC Apc;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||||
Thread, ExitStatus);
|
Thread, ExitStatus);
|
||||||
|
@ -243,6 +245,12 @@ PsTerminateOtherThread(PETHREAD Thread,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
KernelMode);
|
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
|
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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -71,9 +71,10 @@ HANDLE STDCALL PsGetCurrentThreadId(VOID)
|
||||||
return(PsGetCurrentThread()->Cid.UniqueThread);
|
return(PsGetCurrentThread()->Cid.UniqueThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
static VOID
|
||||||
PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
||||||
{
|
{
|
||||||
|
assert(THREAD_STATE_READY == Thread->Tcb.State);
|
||||||
if (Priority >= MAXIMUM_PRIORITY || Priority < 0)
|
if (Priority >= MAXIMUM_PRIORITY || Priority < 0)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid thread priority\n");
|
DPRINT1("Invalid thread priority\n");
|
||||||
|
@ -269,12 +270,19 @@ PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
|
if (THREAD_STATE_TERMINATED_1 != Thread->Tcb.State)
|
||||||
|
{
|
||||||
if (WaitStatus != NULL)
|
if (WaitStatus != NULL)
|
||||||
{
|
{
|
||||||
Thread->Tcb.WaitStatus = *WaitStatus;
|
Thread->Tcb.WaitStatus = *WaitStatus;
|
||||||
}
|
}
|
||||||
Thread->Tcb.State = THREAD_STATE_READY;
|
Thread->Tcb.State = THREAD_STATE_READY;
|
||||||
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("Can't unblock thread 0x%08x because it's terminating\n", Thread);
|
||||||
|
}
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue