Checked in Petr Matousek's fixes for sending APCs to terminated threads.

svn path=/trunk/; revision=5210
This commit is contained in:
David Welch 2003-07-21 21:36:01 +00:00
parent 8b57be1bf4
commit a3cf0cbc62
3 changed files with 53 additions and 29 deletions

View file

@ -326,6 +326,14 @@ KeInsertQueueApc (PKAPC Apc,
}
TargetThread = Apc->Thread;
if (TargetThread->State == THREAD_STATE_TERMINATED_1 ||
TargetThread->State == THREAD_STATE_TERMINATED_2)
{
KeReleaseSpinLock(&PiApcLock, oldlvl);
return(FALSE);
}
if (Apc->ApcMode == KernelMode)
{
InsertTailList(&TargetThread->ApcState.ApcListHead[0],

View file

@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: debug.c,v 1.10 2003/06/16 19:19:30 hbirr Exp $
/* $Id: debug.c,v 1.11 2003/07/21 21:36:01 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/debug.c
@ -245,21 +245,26 @@ NtGetContextThread(IN HANDLE ThreadHandle,
NULL,
KernelMode,
(PVOID)&Context);
KeInsertQueueApc(&Apc,
(PVOID)&Event,
(PVOID)&AStatus,
IO_NO_INCREMENT);
Status = KeWaitForSingleObject(&Event,
0,
UserMode,
FALSE,
NULL);
if (NT_SUCCESS(Status) && ! NT_SUCCESS(AStatus))
if (!KeInsertQueueApc(&Apc,
(PVOID)&Event,
(PVOID)&AStatus,
IO_NO_INCREMENT))
{
Status = AStatus;
Status = STATUS_THREAD_IS_TERMINATING;
}
else
{
Status = KeWaitForSingleObject(&Event,
0,
UserMode,
FALSE,
NULL);
if (NT_SUCCESS(Status) && !NT_SUCCESS(AStatus))
{
Status = AStatus;
}
}
}
if (NT_SUCCESS(Status))
{
Status = MmCopyToCaller(UnsafeContext, &Context, sizeof(Context));
@ -346,18 +351,24 @@ NtSetContextThread(IN HANDLE ThreadHandle,
NULL,
KernelMode,
(PVOID)&Context);
KeInsertQueueApc(&Apc,
(PVOID)&Event,
(PVOID)&AStatus,
IO_NO_INCREMENT);
Status = KeWaitForSingleObject(&Event,
0,
UserMode,
FALSE,
NULL);
if (NT_SUCCESS(Status) && ! NT_SUCCESS(AStatus))
if (!KeInsertQueueApc(&Apc,
(PVOID)&Event,
(PVOID)&AStatus,
IO_NO_INCREMENT))
{
Status = AStatus;
Status = STATUS_THREAD_IS_TERMINATING;
}
else
{
Status = KeWaitForSingleObject(&Event,
0,
UserMode,
FALSE,
NULL);
if (NT_SUCCESS(Status) && !NT_SUCCESS(AStatus))
{
Status = AStatus;
}
}
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: suspend.c,v 1.11 2003/06/05 23:36:35 gdalsnes Exp $
/* $Id: suspend.c,v 1.12 2003/07/21 21:36:01 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/suspend.c
@ -110,10 +110,15 @@ PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
Thread->Tcb.SuspendCount++;
if (!Thread->Tcb.SuspendApc.Inserted)
{
KeInsertQueueApc(&Thread->Tcb.SuspendApc,
NULL,
NULL,
IO_NO_INCREMENT);
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)