mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 14:03:02 +00:00
[DCOMLAUNCH][WMISVC] Stop busy waiting shutdown
This commit is contained in:
parent
bd0a28d1e4
commit
e5b0087c8e
2 changed files with 18 additions and 12 deletions
|
@ -25,6 +25,7 @@ static WCHAR ServiceName[] = L"dcomlaunch";
|
||||||
|
|
||||||
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
||||||
static SERVICE_STATUS ServiceStatus;
|
static SERVICE_STATUS ServiceStatus;
|
||||||
|
static HANDLE ShutdownEvent;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -62,7 +63,8 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
{
|
{
|
||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
SetEvent(ShutdownEvent);
|
||||||
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
case SERVICE_CONTROL_PAUSE:
|
case SERVICE_CONTROL_PAUSE:
|
||||||
|
@ -83,7 +85,8 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
|
|
||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
SetEvent(ShutdownEvent);
|
||||||
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -111,14 +114,14 @@ ServiceMain(DWORD argc, LPTSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShutdownEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
DealWithDeviceEvent();
|
DealWithDeviceEvent();
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_RUNNING);
|
UpdateServiceStatus(SERVICE_RUNNING);
|
||||||
|
|
||||||
do
|
WaitForSingleObject(ShutdownEvent, INFINITE);
|
||||||
{
|
CloseHandle(ShutdownEvent);
|
||||||
Sleep(1);
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
UpdateServiceStatus(SERVICE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ static WCHAR ServiceName[] = L"winmgmt";
|
||||||
|
|
||||||
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
||||||
static SERVICE_STATUS ServiceStatus;
|
static SERVICE_STATUS ServiceStatus;
|
||||||
|
static HANDLE ShutdownEvent;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -81,7 +82,8 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
{
|
{
|
||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
SetEvent(ShutdownEvent);
|
||||||
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
case SERVICE_CONTROL_PAUSE:
|
case SERVICE_CONTROL_PAUSE:
|
||||||
|
@ -102,7 +104,8 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
|
|
||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
SetEvent(ShutdownEvent);
|
||||||
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -128,12 +131,12 @@ ServiceMain(DWORD argc, LPTSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShutdownEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_RUNNING);
|
UpdateServiceStatus(SERVICE_RUNNING);
|
||||||
|
|
||||||
do
|
WaitForSingleObject(ShutdownEvent, INFINITE);
|
||||||
{
|
CloseHandle(ShutdownEvent);
|
||||||
Sleep(1);
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
UpdateServiceStatus(SERVICE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue