Author: tkreuzer
Date: Fri Feb 18 15:01:00 2011
New Revision: 50803
URL:
http://svn.reactos.org/svn/reactos?rev=50803&view=rev
Log:
[CSRSRV]
Dereference all threads, when a process is terminated. Fixes ghost processes in taskmgr!
Patch by Rafal Harabien, <rafalh1992 AT o2 DOT pl>
See issue #1567 for more details.
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Fri Feb 18
15:01:00 2011
@@ -145,6 +145,8 @@
ULONG hash;
PCSRSS_PROCESS_DATA pProcessData, *pPrevLink;
HANDLE Process;
+ PLIST_ENTRY NextEntry;
+ PCSR_THREAD Thread;
hash = ((ULONG_PTR)Pid >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData));
pPrevLink = &ProcessData[hash];
@@ -161,14 +163,27 @@
DPRINT("CsrFreeProcessData pid: %d\n", Pid);
Process = pProcessData->Process;
CallProcessDeleted(pProcessData);
+
+ /* Dereference all process threads */
+ NextEntry = pProcessData->ThreadList.Flink;
+ while (NextEntry != &pProcessData->ThreadList)
+ {
+ Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
+ NextEntry = NextEntry->Flink;
+
+ CsrThreadRefcountZero(Thread);
+ }
+
if (pProcessData->CsrSectionViewBase)
{
NtUnmapViewOfSection(NtCurrentProcess(), pProcessData->CsrSectionViewBase);
}
+
if (pProcessData->ServerCommunicationPort)
{
NtClose(pProcessData->ServerCommunicationPort);
}
+
*pPrevLink = pProcessData->next;
RtlFreeHeap(CsrssApiHeap, 0, pProcessData);