(service_stoppped,stop_service,loc_Ctrl_C_Handler,
empth_request_shutdown,loc_BlockMainThread,empth_init, service_ctrl_handler) [_WIN32]: Remove the Windows Build UI and replace with Ctrl-c signal trap. The shutdown event that was used for STOPPING the service is now used for both foreground and background (service) modes of operation. Also move the shutdown event from service code to empth_t library.
This commit is contained in:
parent
d8938a1605
commit
9227a314c5
4 changed files with 71 additions and 30 deletions
|
@ -149,7 +149,6 @@ remove_service(char *service_name)
|
|||
|
||||
static SERVICE_STATUS service_status;
|
||||
static SERVICE_STATUS_HANDLE service_status_handle;
|
||||
static HANDLE hShutdownEvent = NULL;
|
||||
|
||||
void WINAPI
|
||||
service_ctrl_handler(DWORD Opcode)
|
||||
|
@ -168,7 +167,7 @@ service_ctrl_handler(DWORD Opcode)
|
|||
|
||||
case SERVICE_CONTROL_STOP:
|
||||
logerror("Service stopping");
|
||||
SetEvent(hShutdownEvent);
|
||||
empth_request_shutdown();
|
||||
return;
|
||||
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
|
@ -206,12 +205,6 @@ service_main(DWORD argc, LPTSTR *argv)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((hShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL) {
|
||||
logerror("CreateEvent for Shutdown failed %d\n", GetLastError());
|
||||
finish_server();
|
||||
return;
|
||||
}
|
||||
|
||||
start_server(0);
|
||||
|
||||
/* Initialization complete - report running status. */
|
||||
|
@ -229,14 +222,6 @@ service_main(DWORD argc, LPTSTR *argv)
|
|||
finish_server();
|
||||
}
|
||||
|
||||
void
|
||||
service_stopped(void)
|
||||
{
|
||||
if (hShutdownEvent != NULL) {
|
||||
WaitForSingleObject(hShutdownEvent,INFINITE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
stop_service(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue