[CONSRV]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 1 Jan 2013 02:59:31 +0000 (02:59 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 1 Jan 2013 02:59:31 +0000 (02:59 +0000)
- 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
subsystems/win32/csrsrv/procsup.c
subsystems/win32/csrsrv/thredsup.c

index 0aa184d..80e3d9d 100644 (file)
@@ -625,6 +625,9 @@ CsrApiRequestThread(IN PVOID Parameter)
                 ClientDiedMsg = (PCLIENT_DIED_MSG)&ReceiveMsg;
                 if (ClientDiedMsg->CreateTime.QuadPart == CsrThread->CreateTime.QuadPart)
                 {
                 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);
 
                     /* Reference the thread */
                     CsrLockedReferenceThread(CsrThread);
 
@@ -773,12 +776,14 @@ CsrApiRequestThread(IN PVOID Parameter)
 
         if (CsrDebug & 2)
         {
 
         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],
                     Teb->ClientId.UniqueThread,
                     ReceiveMsg.Header.ClientId.UniqueProcess,
                     ReceiveMsg.Header.ClientId.UniqueThread,
                     ServerDll->NameTable[ApiId],
-                    CsrThread);
+                    CsrThread,
+                    CsrThread->Process,
+                    CsrProcess);
         }
 
         /* Assume success */
         }
 
         /* Assume success */
index 97dd0cb..b516dbf 100644 (file)
@@ -268,8 +268,8 @@ CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
     {
         /* Call the generic cleanup code */
         DPRINT1("Should kill process: %p\n", CsrProcess);
     {
         /* Call the generic cleanup code */
         DPRINT1("Should kill process: %p\n", CsrProcess);
-        CsrProcessRefcountZero(CsrProcess);
         CsrAcquireProcessLock();
         CsrAcquireProcessLock();
+        CsrProcessRefcountZero(CsrProcess);
     }
 }
 
     }
 }
 
@@ -305,7 +305,7 @@ CsrAllocateProcess(VOID)
     if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5;
 
     /* Increase the reference count */
     if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5;
 
     /* Increase the reference count */
-    CsrProcess->ReferenceCount++;
+    CsrLockedReferenceProcess(CsrProcess);
 
     /* Initialize the Thread List */
     InitializeListHead(&CsrProcess->ThreadList);
 
     /* Initialize the Thread List */
     InitializeListHead(&CsrProcess->ThreadList);
@@ -1300,7 +1300,7 @@ CsrShutdownProcesses(IN PLUID CallerLuid,
         if (!CsrProcess) break;
 
         /* Increase reference to process */
         if (!CsrProcess) break;
 
         /* Increase reference to process */
-        CsrProcess->ReferenceCount++;
+        CsrLockedReferenceProcess(CsrProcess);
 
         FirstTry = TRUE;
         while (TRUE)
 
         FirstTry = TRUE;
         while (TRUE)
index 5b74aa4..d7238d2 100644 (file)
@@ -123,11 +123,11 @@ CsrAllocateThread(IN PCSR_PROCESS CsrProcess)
 
     /* Allocate the structure */
     CsrThread = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, sizeof(CSR_THREAD));
 
     /* 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 */
 
     /* Reference the Thread and Process */
-    CsrThread->ReferenceCount++;
-    CsrProcess->ReferenceCount++;
+    CsrLockedReferenceThread(CsrThread);
+    CsrLockedReferenceProcess(CsrProcess);
 
     /* Set the Parent Process */
     CsrThread->Process = CsrProcess;
 
     /* Set the Parent Process */
     CsrThread->Process = CsrProcess;
@@ -465,8 +465,8 @@ CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
     if (!LockCount)
     {
         /* Call the generic cleanup code */
     if (!LockCount)
     {
         /* Call the generic cleanup code */
-        CsrThreadRefcountZero(CsrThread);
         CsrAcquireProcessLock();
         CsrAcquireProcessLock();
+        CsrThreadRefcountZero(CsrThread);
     }
 }
 
     }
 }
 
@@ -991,7 +991,7 @@ CsrLockThreadByClientId(IN HANDLE Tid,
     {
         /* Reference the found thread */
         Status = STATUS_SUCCESS;
     {
         /* Reference the found thread */
         Status = STATUS_SUCCESS;
-        CurrentThread->ReferenceCount++;
+        CsrLockedReferenceThread(CurrentThread);
         *CsrThread = CurrentThread;
     }
     else
         *CsrThread = CurrentThread;
     }
     else