Commit in reactos/ntoskrnl/ps on MAIN
kill.c+12-31.86 -> 1.87
- Prevent from terminate a thread for twice.  
- Don't call KeCancelTimer for the thread timer if the thread lock is held.

reactos/ntoskrnl/ps
kill.c 1.86 -> 1.87
diff -u -r1.86 -r1.87
--- kill.c	21 Nov 2004 18:42:58 -0000	1.86
+++ kill.c	27 Nov 2004 16:47:05 -0000	1.87
@@ -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
  * PROJECT:         ReactOS kernel
@@ -129,6 +129,8 @@
                      (ULONG) CurrentThread);
      }
 
+   KeCancelTimer(&CurrentThread->Tcb.Timer);
+
    KeAcquireSpinLock(&PiThreadLock, &oldIrql);
 
    DPRINT("terminating %x\n",CurrentThread);
@@ -136,7 +138,6 @@
    CurrentThread->HasTerminated = TRUE;
    CurrentThread->ExitStatus = ExitStatus;
    KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->ExitTime);
-   KeCancelTimer(&CurrentThread->Tcb.Timer);
 
    /* If the ProcessoR Control Block's NpxThread points to the current thread
     * unset it.
@@ -175,6 +176,7 @@
          MmReleaseMemoryAreaIfDecommitted(CurrentProcess, &CurrentProcess->AddressSpace, TebBlock);
          MmUnlockAddressSpace(&CurrentProcess->AddressSpace);
        }
+     CurrentThread->Tcb.Teb = NULL;
      ExReleaseFastMutex(&CurrentProcess->TebLock);
    }
 
@@ -257,8 +259,15 @@
 
   DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
 	 Thread, ExitStatus);
-  
+
+  KeAcquireSpinLock(&PiThreadLock, &OldIrql);
+  if (Thread->HasTerminated)
+  {
+     KeReleaseSpinLock(&PiThreadLock, OldIrql);
+     return;
+  }
   Thread->HasTerminated = TRUE;
+  KeReleaseSpinLock(&PiThreadLock, OldIrql);
   Thread->ExitStatus = ExitStatus;
   Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
   KeInitializeApc(Apc,
CVSspam 0.2.8