- Start the RPC-Server from a separate thread so the initial call to the DLL doesn...
authorEric Kohl <eric.kohl@reactos.org>
Sun, 23 Nov 2008 22:39:43 +0000 (22:39 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 23 Nov 2008 22:39:43 +0000 (22:39 +0000)
- Ensure the server accepts more than a single call from clients.

svn path=/trunk/; revision=37599

reactos/dll/win32/lsasrv/lsarpc.c

index 19d0715..679b321 100644 (file)
@@ -57,6 +57,7 @@ ReferencePolicyHandle(IN LSAPR_HANDLE ObjectHandle,
     return Status;
 }
 
     return Status;
 }
 
+
 /*static*/ VOID
 DereferencePolicyHandle(IN OUT PLSAR_POLICY_HANDLE Policy,
                         IN BOOLEAN Delete)
 /*static*/ VOID
 DereferencePolicyHandle(IN OUT PLSAR_POLICY_HANDLE Policy,
                         IN BOOLEAN Delete)
@@ -81,17 +82,13 @@ DereferencePolicyHandle(IN OUT PLSAR_POLICY_HANDLE Policy,
     RtlLeaveCriticalSection(&PolicyHandleTableLock);
 }
 
     RtlLeaveCriticalSection(&PolicyHandleTableLock);
 }
 
-VOID
-LsarStartRpcServer(VOID)
+
+DWORD STDCALL
+LsapRpcThreadRoutine(LPVOID lpParameter)
 {
     RPC_STATUS Status;
 
 {
     RPC_STATUS Status;
 
-    RtlInitializeCriticalSection(&PolicyHandleTableLock);
-    RtlInitializeHandleTable(0x1000,
-                             sizeof(LSAR_POLICY_HANDLE),
-                             &PolicyHandleTable);
-
-    TRACE("LsarStartRpcServer() called");
+    TRACE("LsapRpcThreadRoutine() called");
 
     Status = RpcServerUseProtseqEpW(L"ncacn_np",
                                     10,
 
     Status = RpcServerUseProtseqEpW(L"ncacn_np",
                                     10,
@@ -100,7 +97,7 @@ LsarStartRpcServer(VOID)
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
-        return;
+        return 0;
     }
 
     Status = RpcServerRegisterIf(lsarpc_v0_0_s_ifspec,
     }
 
     Status = RpcServerRegisterIf(lsarpc_v0_0_s_ifspec,
@@ -109,17 +106,51 @@ LsarStartRpcServer(VOID)
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerRegisterIf() failed (Status %lx)\n", Status);
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerRegisterIf() failed (Status %lx)\n", Status);
-        return;
+        return 0;
     }
 
     }
 
-    Status = RpcServerListen(1, 20, TRUE);
+    Status = RpcServerListen(1, 20, FALSE);
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerListen() failed (Status %lx)\n", Status);
     if (Status != RPC_S_OK)
     {
         WARN("RpcServerListen() failed (Status %lx)\n", Status);
-        return;
+        return 0;
     }
 
     }
 
-    TRACE("LsarStartRpcServer() done\n");
+    TRACE("LsapRpcThreadRoutine() done\n");
+
+    return 0;
+}
+
+
+VOID
+LsarStartRpcServer(VOID)
+{
+    HANDLE hThread;
+
+    TRACE("LsarStartRpcServer() called");
+
+    RtlInitializeCriticalSection(&PolicyHandleTableLock);
+    RtlInitializeHandleTable(0x1000,
+                             sizeof(LSAR_POLICY_HANDLE),
+                             &PolicyHandleTable);
+
+    hThread = CreateThread(NULL,
+                           0,
+                           (LPTHREAD_START_ROUTINE)
+                           LsapRpcThreadRoutine,
+                           NULL,
+                           0,
+                           NULL);
+    if (!hThread)
+    {
+        WARN("Starting LsapRpcThreadRoutine-Thread failed!\n");
+    }
+    else
+    {
+        CloseHandle(hThread);
+    }
+
+    TRACE("LsarStartRpcServer() done");
 }
 
 
 }
 
 
@@ -220,8 +251,16 @@ NTSTATUS LsarOpenPolicy(
     ACCESS_MASK DesiredAccess,
     LSAPR_HANDLE *PolicyHandle)
 {
     ACCESS_MASK DesiredAccess,
     LSAPR_HANDLE *PolicyHandle)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+    ERR("LsarOpenPolicy called!\n");
+
+    *PolicyHandle = (LSAPR_HANDLE)0xcafe;
+
+    ERR("LsarOpenPolicy done!\n");
+
+    return STATUS_SUCCESS;
+
+//    UNIMPLEMENTED;
+//    return STATUS_NOT_IMPLEMENTED;
 }
 
 
 }