Commit in reactos/subsys/csrss on MAIN
api/wapi.c+38-181.36 -> 1.37
init.c+14-101.27 -> 1.28
include/api.h+3-21.4 -> 1.5
+55-30
3 modified files
- Try to get or to allocate the process data structure in ServerApiPortThread.  
- Changed the initialization sequence in CsrServerInitialization.

reactos/subsys/csrss/api
wapi.c 1.36 -> 1.37
diff -u -r1.36 -r1.37
--- wapi.c	27 Jun 2004 12:21:32 -0000	1.36
+++ wapi.c	3 Jul 2004 17:15:02 -0000	1.37
@@ -1,4 +1,4 @@
-/* $Id: wapi.c,v 1.36 2004/06/27 12:21:32 weiden Exp $
+/* $Id: wapi.c,v 1.37 2004/07/03 17:15:02 hbirr Exp $
  * 
  * reactos/subsys/csrss/api/wapi.c
  *
@@ -97,8 +97,8 @@
     }
 }
 
-static void
-Thread_Api2(HANDLE ServerPort)
+static void STDCALL
+ClientConnectionThread(HANDLE ServerPort)
 {
   NTSTATUS Status;
   LPC_MAX_MESSAGE LpcReply;
@@ -118,26 +118,31 @@
       if (! NT_SUCCESS(Status))
         {
           DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
-          NtClose(ServerPort);
-          RtlRosExitUserThread(Status);
-          continue;
+          break;
         }
 	
       if (LpcRequest.Header.MessageType == LPC_PORT_CLOSED)
         {
           CsrFreeProcessData( (ULONG)LpcRequest.Header.ClientId.UniqueProcess );
-          NtClose(ServerPort);
-          RtlRosExitUserThread(STATUS_SUCCESS);
-          continue;
+          break;
         }
 
       Request = (PCSRSS_API_REQUEST)&LpcRequest;
       Reply = (PCSRSS_API_REPLY)&LpcReply;
 	
       ProcessData = CsrGetProcessData((ULONG)LpcRequest.Header.ClientId.UniqueProcess);
+      if (ProcessData == NULL)
+        {
+          DPRINT1("CSR: Message %d: Unable to find data for process %d\n",
+	          LpcRequest.Header.MessageType, (ULONG)LpcRequest.Header.ClientId.UniqueProcess);
+	  break;
+        }	          
+
 
       CsrApiCallHandler(ProcessData, Request, Reply);
     }
+  NtClose(ServerPort);
+  RtlRosExitUserThread(STATUS_SUCCESS);
 }
 
 /**********************************************************************
@@ -148,7 +153,8 @@
  * 	Handle connection requests from clients to the port
  * 	"\Windows\ApiPort".
  */
-void Thread_Api(PVOID PortHandle)
+void STDCALL
+ServerApiPortThead(PVOID PortHandle)
 {
    NTSTATUS Status;
    LPC_MAX_MESSAGE Request;
@@ -161,14 +167,14 @@
    for (;;)
      {
         LPC_SECTION_READ LpcRead;
+        ServerPort = NULL;
 
 	Status = NtListenPort(PortHandle, &Request.Header);
 	if (!NT_SUCCESS(Status))
 	  {
 	     DPRINT1("CSR: NtListenPort() failed\n");
-	     NtTerminateThread(NtCurrentThread(), Status);
+	     break;
 	  }
-	
 	Status = NtAcceptConnectPort(&ServerPort,
 				     PortHandle,
 				     NULL,
@@ -178,10 +184,19 @@
 	if (!NT_SUCCESS(Status))
 	  {
 	     DPRINT1("CSR: NtAcceptConnectPort() failed\n");
-	     NtTerminateThread(NtCurrentThread(), Status);
+	     break;
+	  }
+
+	ProcessData = CsrCreateProcessData((ULONG)Request.Header.ClientId.UniqueProcess);
+	if (ProcessData == NULL)
+	  {
+	     DPRINT1("Unable to allocate or find data for process %d\n",
+	             (ULONG)Request.Header.ClientId.UniqueProcess);
+	     Status = STATUS_UNSUCCESSFUL;
+	     break;
 	  }
+	    
 
-	ProcessData = CsrGetProcessData((ULONG)Request.Header.ClientId.UniqueProcess);
 	ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
 	ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
 	
@@ -189,7 +204,7 @@
 	if (!NT_SUCCESS(Status))
 	  {
 	     DPRINT1("CSR: NtCompleteConnectPort() failed\n");
-	     NtTerminateThread(NtCurrentThread(), Status);
+	     break;
 	  }
 	
 	Status = RtlCreateUserThread(NtCurrentProcess(),
@@ -198,18 +213,23 @@
 				     0,
 				     NULL,
 				     NULL,
-				     (PTHREAD_START_ROUTINE)Thread_Api2,
+				     (PTHREAD_START_ROUTINE)ClientConnectionThread,
 				     ServerPort,
 				     &ServerThread,
 				     NULL);
 	if (!NT_SUCCESS(Status))
 	  {
 	     DPRINT1("CSR: Unable to create server thread\n");
-	     NtClose(ServerPort);
-	     NtTerminateThread(NtCurrentThread(), Status);
+	     break;
 	  }
 	NtClose(ServerThread);
      }
+   if (ServerPort)
+     {
+       NtClose(ServerPort);
+     }
+   NtClose(PortHandle);
+   NtTerminateThread(NtCurrentThread(), Status);
 }
 
 /* EOF */

reactos/subsys/csrss
init.c 1.27 -> 1.28
diff -u -r1.27 -r1.28
--- init.c	28 May 2004 21:33:41 -0000	1.27
+++ init.c	3 Jul 2004 17:15:02 -0000	1.28
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.27 2004/05/28 21:33:41 gvg Exp $
+/* $Id: init.c,v 1.28 2004/07/03 17:15:02 hbirr Exp $
  * 
  * reactos/subsys/csrss/init.c
  *
@@ -249,7 +249,6 @@
       return FALSE;
     }
 
-  CsrIsCsrss( );
   CsrInitVideo();
 
   CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
@@ -270,13 +269,6 @@
       return Status;
     }
 
-  Status = InitWin32Csr();
-  if (! NT_SUCCESS(Status))
-    {
-      DPRINT1("CSR: Unable to load usermode dll (Status %x)\n", Status);
-      return FALSE;
-    }
-
   /* NEW NAMED PORT: \ApiPort */
   RtlRosInitUnicodeStringFromLiteral(&PortName, L"\\Windows\\ApiPort");
   InitializeObjectAttributes(&ObAttributes,
@@ -300,7 +292,7 @@
                                0,
                                NULL,
                                NULL,
-                               (PTHREAD_START_ROUTINE)Thread_Api,
+                               (PTHREAD_START_ROUTINE)ServerApiPortThead,
                                ApiPortHandle,
                                NULL,
                                NULL);
@@ -310,6 +302,18 @@
       NtClose(ApiPortHandle);
       return FALSE;
     }
+  Status = CsrClientConnectToServer();
+  if (!NT_SUCCESS(Status))
+    {
+      DPRINT1("CsrClientConnectToServer() failed (Status %x)\n", Status);
+      return FALSE;
+    }
+  Status = InitWin32Csr();
+  if (! NT_SUCCESS(Status))
+    {
+      DPRINT1("CSR: Unable to load usermode dll (Status %x)\n", Status);
+      return FALSE;
+    }
 
   return CallInitComplete();
 }

reactos/subsys/csrss/include
api.h 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- api.h	11 Jan 2004 17:31:15 -0000	1.4
+++ api.h	3 Jul 2004 17:15:02 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: api.h,v 1.4 2004/01/11 17:31:15 gvg Exp $
+/* $Id: api.h,v 1.5 2004/07/03 17:15:02 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -96,7 +96,7 @@
 VOID FASTCALL CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
                                 PCSRSS_API_REQUEST Request,
                                 PCSRSS_API_REPLY Reply);
-VOID Thread_Api(PVOID PortHandle);
+VOID STDCALL ServerApiPortThead(PVOID PortHandle);
 VOID Console_Api( DWORD Ignored );
 
 extern HANDLE CsrssApiHeap;
@@ -107,6 +107,7 @@
 /* api/process.c */
 VOID STDCALL CsrInitProcessData(VOID);
 PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId);
+PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(ULONG ProcessId);
 NTSTATUS STDCALL CsrFreeProcessData( ULONG Pid );
 
 /* api/handle.c */
CVSspam 0.2.8