[SERVICES] When autostart services are up, signal an event.

[SYSSETUP] Wait until all autostart services are up. Bug #4194.

Patches by Dmitry Gorbachev.
See issue #4142 for more details.

svn path=/trunk/; revision=45633
This commit is contained in:
Eric Kohl 2010-02-20 13:04:56 +00:00
parent 8ab0f28658
commit ad0ec3b76b
2 changed files with 39 additions and 23 deletions

View file

@ -48,35 +48,34 @@ PrintString(LPCSTR fmt, ...)
BOOL BOOL
ScmCreateStartEvent(PHANDLE StartEvent) ScmCreateEvent(PHANDLE Event,
LPCWSTR Name)
{ {
HANDLE hEvent; HANDLE hEvent;
hEvent = CreateEvent(NULL, hEvent = CreateEventW(NULL,
TRUE, TRUE,
FALSE, FALSE,
TEXT("SvcctrlStartEvent_A3752DX")); Name);
if (hEvent == NULL) if (hEvent == NULL)
{ {
if (GetLastError() == ERROR_ALREADY_EXISTS) if (GetLastError() == ERROR_ALREADY_EXISTS)
{ {
hEvent = OpenEvent(EVENT_ALL_ACCESS, hEvent = OpenEventW(EVENT_ALL_ACCESS,
FALSE, FALSE,
TEXT("SvcctrlStartEvent_A3752DX")); Name);
if (hEvent == NULL)
{
return FALSE;
}
}
else
{
return FALSE;
} }
} }
*StartEvent = hEvent; if (hEvent)
{
DPRINT("SERVICES: created event %S with handle %x\n", Name, hEvent);
*Event = hEvent;
return TRUE; return TRUE;
}
DPRINT1("SERVICES: Failed to create event %S\n", Name);
return FALSE;
} }
@ -299,6 +298,7 @@ wWinMain(HINSTANCE hInstance,
int nShowCmd) int nShowCmd)
{ {
HANDLE hScmStartEvent; HANDLE hScmStartEvent;
HANDLE hScmAutoStartCompleteEvent;
HANDLE hEvent; HANDLE hEvent;
DWORD dwError; DWORD dwError;
@ -307,14 +307,16 @@ wWinMain(HINSTANCE hInstance,
/* Acquire privileges to load drivers */ /* Acquire privileges to load drivers */
AcquireLoadDriverPrivilege(); AcquireLoadDriverPrivilege();
/* Create start event */ /* Create events */
if (!ScmCreateStartEvent(&hScmStartEvent)) if (!ScmCreateEvent(&hScmAutoStartCompleteEvent, L"SC_AutoStartComplete"))
{ {
DPRINT1("SERVICES: Failed to create start event\n");
ExitThread(0); ExitThread(0);
} }
DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent); if (!ScmCreateEvent(&hScmStartEvent, L"SvcctrlStartEvent_A3752DX"))
{
ExitThread(0);
}
// ScmInitThreadManager(); // ScmInitThreadManager();
@ -354,6 +356,9 @@ wWinMain(HINSTANCE hInstance,
DPRINT("SERVICES: Running.\n"); DPRINT("SERVICES: Running.\n");
/* Signal complete event */
SetEvent(hScmAutoStartCompleteEvent);
#if 1 #if 1
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent) if (hEvent)

View file

@ -481,9 +481,20 @@ EnableUserModePnpManager(VOID)
DWORD BytesNeeded = 0; DWORD BytesNeeded = 0;
DWORD dwWaitTime; DWORD dwWaitTime;
DWORD dwMaxWait; DWORD dwMaxWait;
HANDLE hEvent;
BOOL ret = FALSE; BOOL ret = FALSE;
hSCManager = OpenSCManager(NULL, NULL, 0); hEvent = OpenEventW(EVENT_ALL_ACCESS,
FALSE,
L"SC_AutoStartComplete");
if (hEvent == NULL)
goto cleanup;
WaitForSingleObject(hEvent, INFINITE);
hSCManager = OpenSCManager(NULL,
NULL,
SC_MANAGER_CONNECT);
if (hSCManager == NULL) if (hSCManager == NULL)
goto cleanup; goto cleanup;