services: Track number of services per process.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b08ce1ae80
commit
36ccc45db6
|
@ -761,7 +761,8 @@ DWORD __cdecl svcctl_SetServiceStatus(
|
|||
if (lpServiceStatus->dwCurrentState == SERVICE_STOPPED)
|
||||
{
|
||||
service->service_entry->process = NULL;
|
||||
terminate_after_timeout(process, service_kill_timeout);
|
||||
if (!--process->use_count)
|
||||
terminate_after_timeout(process, service_kill_timeout);
|
||||
release_process(process);
|
||||
}
|
||||
else
|
||||
|
@ -1135,7 +1136,11 @@ DWORD __cdecl svcctl_ControlService(
|
|||
{
|
||||
result = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
|
||||
if ((process = service->service_entry->process))
|
||||
process_terminate(process);
|
||||
{
|
||||
service->service_entry->process = NULL;
|
||||
if (!--process->use_count) process_terminate(process);
|
||||
release_process(process);
|
||||
}
|
||||
}
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
|
|
|
@ -752,8 +752,9 @@ static DWORD service_start_process(struct service_entry *service_entry, struct p
|
|||
service_unlock(service_entry);
|
||||
return ERROR_SERVICE_ALREADY_RUNNING;
|
||||
}
|
||||
release_process(process);
|
||||
service_entry->process = NULL;
|
||||
process->use_count--;
|
||||
release_process(process);
|
||||
}
|
||||
|
||||
service_entry->force_shutdown = FALSE;
|
||||
|
@ -784,6 +785,7 @@ static DWORD service_start_process(struct service_entry *service_entry, struct p
|
|||
service_entry->status.dwCurrentState = SERVICE_START_PENDING;
|
||||
scmdatabase_add_process(service_entry->db, process);
|
||||
service_entry->process = grab_process(process);
|
||||
process->use_count++;
|
||||
|
||||
service_unlock(service_entry);
|
||||
|
||||
|
@ -945,6 +947,7 @@ void process_terminate(struct process_entry *process)
|
|||
if (service->process != process) continue;
|
||||
service->status.dwCurrentState = SERVICE_STOPPED;
|
||||
service->process = NULL;
|
||||
process->use_count--;
|
||||
release_process(process);
|
||||
}
|
||||
scmdatabase_unlock(db);
|
||||
|
|
|
@ -37,6 +37,7 @@ struct process_entry
|
|||
struct list entry;
|
||||
struct scmdatabase *db;
|
||||
LONG ref_count;
|
||||
LONG use_count;
|
||||
DWORD process_id;
|
||||
HANDLE process;
|
||||
HANDLE control_mutex;
|
||||
|
|
Loading…
Reference in New Issue