Wait for the SCM to be fully initialized before calling allowing a call to OpenSCManager

svn path=/trunk/; revision=27695
This commit is contained in:
Ged Murphy 2007-07-16 16:00:37 +00:00
parent e47b3f0dfa
commit 972d9788d0
3 changed files with 25 additions and 0 deletions

View file

@ -1511,6 +1511,9 @@ ScmrOpenSCManagerW(handle_t BindingHandle,
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
if (!ScmWaitForEvent())
return ERROR_ACCESS_DENIED;
dwError = ScmCreateManagerHandle(lpDatabaseName,
&hHandle);
if (dwError != ERROR_SUCCESS)

View file

@ -94,6 +94,27 @@ ScmCreateStartEvent(PHANDLE StartEvent)
}
BOOL ScmWaitForEvent()
{
HANDLE hEvent;
hEvent = OpenEvent(EVENT_ALL_ACCESS,
FALSE,
TEXT("SvcctrlStartEvent_A3752DX"));
if (hEvent)
{
DWORD ret = WaitForSingleObject(hEvent,
INFINITE);
if (ret == WAIT_OBJECT_0)
return TRUE;
}
return FALSE;
}
BOOL
ScmNamedPipeHandleRequest(PVOID Request,
DWORD RequestSize,

View file

@ -134,6 +134,7 @@ VOID ScmStartRpcServer(VOID);
/* services.c */
BOOL ScmWaitForEvent();
VOID PrintString(LPCSTR fmt, ...);
/* EOF */