mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
- Prevent from terminate a thread for twice.
- Don't call KeCancelTimer for the thread timer if the thread lock is held. svn path=/trunk/; revision=11839
This commit is contained in:
parent
be30cb2cf0
commit
6c0c99c180
1 changed files with 12 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kill.c,v 1.86 2004/11/21 18:42:58 gdalsnes Exp $
|
/* $Id: kill.c,v 1.87 2004/11/27 16:47:05 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -129,6 +129,8 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
(ULONG) CurrentThread);
|
(ULONG) CurrentThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
DPRINT("terminating %x\n",CurrentThread);
|
DPRINT("terminating %x\n",CurrentThread);
|
||||||
|
@ -136,7 +138,6 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
CurrentThread->HasTerminated = TRUE;
|
CurrentThread->HasTerminated = TRUE;
|
||||||
CurrentThread->ExitStatus = ExitStatus;
|
CurrentThread->ExitStatus = ExitStatus;
|
||||||
KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->ExitTime);
|
KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->ExitTime);
|
||||||
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
|
||||||
|
|
||||||
/* If the ProcessoR Control Block's NpxThread points to the current thread
|
/* If the ProcessoR Control Block's NpxThread points to the current thread
|
||||||
* unset it.
|
* unset it.
|
||||||
|
@ -175,6 +176,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
MmReleaseMemoryAreaIfDecommitted(CurrentProcess, &CurrentProcess->AddressSpace, TebBlock);
|
MmReleaseMemoryAreaIfDecommitted(CurrentProcess, &CurrentProcess->AddressSpace, TebBlock);
|
||||||
MmUnlockAddressSpace(&CurrentProcess->AddressSpace);
|
MmUnlockAddressSpace(&CurrentProcess->AddressSpace);
|
||||||
}
|
}
|
||||||
|
CurrentThread->Tcb.Teb = NULL;
|
||||||
ExReleaseFastMutex(&CurrentProcess->TebLock);
|
ExReleaseFastMutex(&CurrentProcess->TebLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +259,15 @@ PsTerminateOtherThread(PETHREAD Thread,
|
||||||
|
|
||||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||||
Thread, ExitStatus);
|
Thread, ExitStatus);
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PiThreadLock, &OldIrql);
|
||||||
|
if (Thread->HasTerminated)
|
||||||
|
{
|
||||||
|
KeReleaseSpinLock(&PiThreadLock, OldIrql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Thread->HasTerminated = TRUE;
|
Thread->HasTerminated = TRUE;
|
||||||
|
KeReleaseSpinLock(&PiThreadLock, OldIrql);
|
||||||
Thread->ExitStatus = ExitStatus;
|
Thread->ExitStatus = ExitStatus;
|
||||||
Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
|
Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
|
||||||
KeInitializeApc(Apc,
|
KeInitializeApc(Apc,
|
||||||
|
|
Loading…
Reference in a new issue