From 0444a3a392837cefe4d07bcc8713bfd9b2653229 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 1 Jan 2013 02:59:31 +0000 Subject: [PATCH] [CONSRV] - Be sure that we reply to the dying client when he dies. - "Improve" a debug output (display the client process). - Use existing helper functions for incrementing reference counts for threads and processes. svn path=/branches/ros-csrss/; revision=58075 --- subsystems/win32/csrsrv/api.c | 9 +++++++-- subsystems/win32/csrsrv/procsup.c | 6 +++--- subsystems/win32/csrsrv/thredsup.c | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/subsystems/win32/csrsrv/api.c b/subsystems/win32/csrsrv/api.c index 0aa184d4ad2..80e3d9dd3d4 100644 --- a/subsystems/win32/csrsrv/api.c +++ b/subsystems/win32/csrsrv/api.c @@ -625,6 +625,9 @@ CsrApiRequestThread(IN PVOID Parameter) ClientDiedMsg = (PCLIENT_DIED_MSG)&ReceiveMsg; if (ClientDiedMsg->CreateTime.QuadPart == CsrThread->CreateTime.QuadPart) { + /* Now we reply to the dying client */ + ReplyPort = CsrThread->Process->ClientPort; + /* Reference the thread */ CsrLockedReferenceThread(CsrThread); @@ -773,12 +776,14 @@ CsrApiRequestThread(IN PVOID Parameter) if (CsrDebug & 2) { - DPRINT1("[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x\n", + DPRINT1("[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x, Process %08x - %08x\n", Teb->ClientId.UniqueThread, ReceiveMsg.Header.ClientId.UniqueProcess, ReceiveMsg.Header.ClientId.UniqueThread, ServerDll->NameTable[ApiId], - CsrThread); + CsrThread, + CsrThread->Process, + CsrProcess); } /* Assume success */ diff --git a/subsystems/win32/csrsrv/procsup.c b/subsystems/win32/csrsrv/procsup.c index 97dd0cb8f98..b516dbf606a 100644 --- a/subsystems/win32/csrsrv/procsup.c +++ b/subsystems/win32/csrsrv/procsup.c @@ -268,8 +268,8 @@ CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess) { /* Call the generic cleanup code */ DPRINT1("Should kill process: %p\n", CsrProcess); - CsrProcessRefcountZero(CsrProcess); CsrAcquireProcessLock(); + CsrProcessRefcountZero(CsrProcess); } } @@ -305,7 +305,7 @@ CsrAllocateProcess(VOID) if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5; /* Increase the reference count */ - CsrProcess->ReferenceCount++; + CsrLockedReferenceProcess(CsrProcess); /* Initialize the Thread List */ InitializeListHead(&CsrProcess->ThreadList); @@ -1300,7 +1300,7 @@ CsrShutdownProcesses(IN PLUID CallerLuid, if (!CsrProcess) break; /* Increase reference to process */ - CsrProcess->ReferenceCount++; + CsrLockedReferenceProcess(CsrProcess); FirstTry = TRUE; while (TRUE) diff --git a/subsystems/win32/csrsrv/thredsup.c b/subsystems/win32/csrsrv/thredsup.c index 5b74aa4d901..d7238d2fc13 100644 --- a/subsystems/win32/csrsrv/thredsup.c +++ b/subsystems/win32/csrsrv/thredsup.c @@ -123,11 +123,11 @@ CsrAllocateThread(IN PCSR_PROCESS CsrProcess) /* Allocate the structure */ CsrThread = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, sizeof(CSR_THREAD)); - if (!CsrThread) return(NULL); + if (!CsrThread) return NULL; /* Reference the Thread and Process */ - CsrThread->ReferenceCount++; - CsrProcess->ReferenceCount++; + CsrLockedReferenceThread(CsrThread); + CsrLockedReferenceProcess(CsrProcess); /* Set the Parent Process */ CsrThread->Process = CsrProcess; @@ -465,8 +465,8 @@ CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread) if (!LockCount) { /* Call the generic cleanup code */ - CsrThreadRefcountZero(CsrThread); CsrAcquireProcessLock(); + CsrThreadRefcountZero(CsrThread); } } @@ -991,7 +991,7 @@ CsrLockThreadByClientId(IN HANDLE Tid, { /* Reference the found thread */ Status = STATUS_SUCCESS; - CurrentThread->ReferenceCount++; + CsrLockedReferenceThread(CurrentThread); *CsrThread = CurrentThread; } else -- 2.17.1