Notify StartService when service control dispatcher has been
started. Otherwise StartService terminates service process.
This commit is contained in:
parent
cd0970eb24
commit
9087fb2000
|
@ -46,6 +46,9 @@ static const WCHAR szServiceMutexNameFmtW[] = {'A','D','V','A','P','I','_',
|
||||||
'M','U','X','_','%','s',0};
|
'M','U','X','_','%','s',0};
|
||||||
static const WCHAR szServiceAckEventNameFmtW[] = {'A','D','V','A','P','I','_',
|
static const WCHAR szServiceAckEventNameFmtW[] = {'A','D','V','A','P','I','_',
|
||||||
'A','C','K','_','%','s',0};
|
'A','C','K','_','%','s',0};
|
||||||
|
static const WCHAR szWaitServiceStartW[] = {'A','D','V','A','P','I','_','W',
|
||||||
|
'a','i','t','S','e','r','v','i',
|
||||||
|
'c','e','S','t','a','r','t',0};
|
||||||
|
|
||||||
struct SEB /* service environment block */
|
struct SEB /* service environment block */
|
||||||
{ /* resides in service's shared memory object */
|
{ /* resides in service's shared memory object */
|
||||||
|
@ -472,6 +475,7 @@ error:
|
||||||
static BOOL service_ctrl_dispatcher( LPSERVICE_TABLE_ENTRYW servent, BOOL ascii )
|
static BOOL service_ctrl_dispatcher( LPSERVICE_TABLE_ENTRYW servent, BOOL ascii )
|
||||||
{
|
{
|
||||||
WCHAR object_name[ MAX_PATH ];
|
WCHAR object_name[ MAX_PATH ];
|
||||||
|
HANDLE wait;
|
||||||
|
|
||||||
/* FIXME: if shared service, find entry by service name */
|
/* FIXME: if shared service, find entry by service name */
|
||||||
|
|
||||||
|
@ -504,6 +508,14 @@ static BOOL service_ctrl_dispatcher( LPSERVICE_TABLE_ENTRYW servent, BOOL ascii
|
||||||
/* ready to accept control requests */
|
/* ready to accept control requests */
|
||||||
ReleaseMutex( service->mutex );
|
ReleaseMutex( service->mutex );
|
||||||
|
|
||||||
|
/* signal for StartService */
|
||||||
|
wait = OpenSemaphoreW( SEMAPHORE_MODIFY_STATE, FALSE, szWaitServiceStartW );
|
||||||
|
if( wait )
|
||||||
|
{
|
||||||
|
ReleaseSemaphore( wait, 1, NULL );
|
||||||
|
CloseHandle( wait );
|
||||||
|
}
|
||||||
|
|
||||||
/* dispatcher loop */
|
/* dispatcher loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -1223,9 +1235,6 @@ BOOL WINAPI
|
||||||
StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
LPCWSTR *lpServiceArgVectors )
|
LPCWSTR *lpServiceArgVectors )
|
||||||
{
|
{
|
||||||
static const WCHAR _WaitServiceStartW[] = {'A','D','V','A','P','I','_','W',
|
|
||||||
'a','i','t','S','e','r','v','i',
|
|
||||||
'c','e','S','t','a','r','t',0};
|
|
||||||
static const WCHAR _ImagePathW[] = {'I','m','a','g','e','P','a','t','h',0};
|
static const WCHAR _ImagePathW[] = {'I','m','a','g','e','P','a','t','h',0};
|
||||||
|
|
||||||
struct sc_handle *hsvc = hService;
|
struct sc_handle *hsvc = hService;
|
||||||
|
@ -1306,7 +1315,7 @@ StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
argptr += 1 + strlenW( argptr );
|
argptr += 1 + strlenW( argptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
wait = CreateSemaphoreW(NULL,0,1,_WaitServiceStartW);
|
wait = CreateSemaphoreW(NULL,0,1,szWaitServiceStartW);
|
||||||
if (!wait)
|
if (!wait)
|
||||||
{
|
{
|
||||||
ERR("Couldn't create wait semaphore\n");
|
ERR("Couldn't create wait semaphore\n");
|
||||||
|
@ -1341,6 +1350,13 @@ StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
CloseHandle( procinfo.hProcess );
|
CloseHandle( procinfo.hProcess );
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if( WAIT_TIMEOUT == r )
|
||||||
|
{
|
||||||
|
TerminateProcess( procinfo.hProcess, 1 );
|
||||||
|
CloseHandle( procinfo.hProcess );
|
||||||
|
SetLastError( ERROR_SERVICE_REQUEST_TIMEOUT );
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* allright */
|
/* allright */
|
||||||
CloseHandle( procinfo.hProcess );
|
CloseHandle( procinfo.hProcess );
|
||||||
|
|
Loading…
Reference in New Issue