Author: ekohl
Date: Sat Dec 13 19:01:16 2008
New Revision: 38065
URL:
http://svn.reactos.org/svn/reactos?rev=38065&view=rev
Log:
- Make the service manager wait for LSA.
- Winlogon must not wait for the service mananger, otherwise we will get another
deadlock.
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/winlogon/winlogon.c
Modified: trunk/reactos/base/system/services/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sat Dec 13 19:01:16 2008
@@ -446,6 +446,46 @@
}
+VOID
+WaitForLSA(VOID)
+{
+ HANDLE hEvent;
+ DWORD dwError;
+
+ DPRINT1("WaitForLSA() called\n");
+
+ hEvent = CreateEventW(NULL,
+ TRUE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ dwError = GetLastError();
+ DPRINT1("Failed to create the notication event (Error %lu)\n",
dwError);
+
+ if (dwError == ERROR_ALREADY_EXISTS)
+ {
+ hEvent = OpenEventW(SYNCHRONIZE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent != NULL)
+ {
+ DPRINT1("Could not open the notification event!\n");
+ return;
+ }
+ }
+ }
+
+ DPRINT1("Wait for LSA!\n");
+ WaitForSingleObject(hEvent, INFINITE);
+ DPRINT1("LSA is available!\n");
+
+ CloseHandle(hEvent);
+
+ DPRINT1("WaitForLSA() done\n");
+}
+
+
DWORD
ScmCreateServiceDatabase(VOID)
{
@@ -515,6 +555,9 @@
}
RegCloseKey(hServicesKey);
+
+ /* Wait for LSA */
+ WaitForLSA();
/* Delete services that are marked for delete */
ScmDeleteMarkedServices();
Modified: trunk/reactos/base/system/winlogon/winlogon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlo…
==============================================================================
--- trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] Sat Dec 13 19:01:16 2008
@@ -26,14 +26,13 @@
static BOOL
StartServicesManager(VOID)
{
- HANDLE ServicesInitEvent = NULL;
STARTUPINFOW StartupInfo;
PROCESS_INFORMATION ProcessInformation;
- DWORD Count;
LPCWSTR ServiceString = L"services.exe";
BOOL res;
/* Start the service control manager (services.exe) */
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
@@ -61,29 +60,11 @@
return FALSE;
}
- /* Wait for event creation (by SCM) for max. 20 seconds */
- for (Count = 0; Count < 20; Count++)
- {
- Sleep(1000);
-
- TRACE("WL: Attempting to open event
\"SvcctrlStartEvent_A3752DX\"\n");
- ServicesInitEvent = OpenEventW(
- SYNCHRONIZE,
- FALSE,
- L"SvcctrlStartEvent_A3752DX");
- if (ServicesInitEvent)
- break;
- }
-
- if (!ServicesInitEvent)
- {
- ERR("WL: Failed to open event \"SvcctrlStartEvent_A3752DX\"\n");
- return FALSE;
- }
-
- /* Wait for event signalization */
- WaitForSingleObject(ServicesInitEvent, INFINITE);
- CloseHandle(ServicesInitEvent);
+ TRACE("WL: Created new process - %S\n", ServiceString);
+
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
+
TRACE("WL: StartServicesManager() done.\n");
return TRUE;
@@ -99,6 +80,7 @@
BOOL res;
/* Start the service control manager (services.exe) */
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
@@ -120,6 +102,11 @@
NULL,
&StartupInfo,
&ProcessInformation);
+
+ TRACE("WL: Created new process - %S\n", ServiceString);
+
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
return res;
}