services: Move service cleanup code to separate function.
This commit is contained in:
parent
bc866c899f
commit
01ef66cb1e
|
@ -1062,6 +1062,11 @@ DWORD __cdecl svcctl_ControlService(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result==ERROR_SUCCESS && !service->service_entry->control_mutex) {
|
||||||
|
result = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
|
||||||
|
service_terminate(service->service_entry);
|
||||||
|
}
|
||||||
|
|
||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (lpServiceStatus)
|
if (lpServiceStatus)
|
||||||
|
|
|
@ -847,27 +847,32 @@ DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *
|
||||||
if (err == ERROR_SUCCESS)
|
if (err == ERROR_SUCCESS)
|
||||||
ReleaseMutex(service->control_mutex);
|
ReleaseMutex(service->control_mutex);
|
||||||
else
|
else
|
||||||
{
|
service_terminate(service);
|
||||||
|
scmdatabase_unlock_startup(service->db);
|
||||||
|
|
||||||
|
WINE_TRACE("returning %d\n", err);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void service_terminate(struct service_entry *service)
|
||||||
|
{
|
||||||
|
service_lock_exclusive(service);
|
||||||
|
TerminateProcess(service->process, 0);
|
||||||
|
CloseHandle(service->process);
|
||||||
|
service->process = NULL;
|
||||||
CloseHandle(service->overlapped_event);
|
CloseHandle(service->overlapped_event);
|
||||||
service->overlapped_event = NULL;
|
service->overlapped_event = NULL;
|
||||||
CloseHandle(service->status_changed_event);
|
CloseHandle(service->status_changed_event);
|
||||||
service->status_changed_event = NULL;
|
service->status_changed_event = NULL;
|
||||||
CloseHandle(service->control_mutex);
|
CloseHandle(service->control_mutex);
|
||||||
service->control_mutex = NULL;
|
service->control_mutex = NULL;
|
||||||
if (service->control_pipe != INVALID_HANDLE_VALUE)
|
|
||||||
CloseHandle(service->control_pipe);
|
CloseHandle(service->control_pipe);
|
||||||
service->control_pipe = INVALID_HANDLE_VALUE;
|
service->control_pipe = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
service->status.dwProcessId = 0;
|
service->status.dwProcessId = 0;
|
||||||
service_lock_exclusive(service);
|
|
||||||
service->status.dwCurrentState = SERVICE_STOPPED;
|
service->status.dwCurrentState = SERVICE_STOPPED;
|
||||||
service_unlock(service);
|
service_unlock(service);
|
||||||
}
|
|
||||||
scmdatabase_unlock_startup(service->db);
|
|
||||||
|
|
||||||
WINE_TRACE("returning %d\n", err);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_registry_parameters(void)
|
static void load_registry_parameters(void)
|
||||||
|
|
|
@ -78,6 +78,7 @@ void service_lock_shared(struct service_entry *service);
|
||||||
void service_lock_exclusive(struct service_entry *service);
|
void service_lock_exclusive(struct service_entry *service);
|
||||||
void service_unlock(struct service_entry *service);
|
void service_unlock(struct service_entry *service);
|
||||||
DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv);
|
DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv);
|
||||||
|
void service_terminate(struct service_entry *service);
|
||||||
BOOL service_send_command( struct service_entry *service, HANDLE pipe,
|
BOOL service_send_command( struct service_entry *service, HANDLE pipe,
|
||||||
const void *data, DWORD size, DWORD *result );
|
const void *data, DWORD size, DWORD *result );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue