Commit 46a97485 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

services: Add a grab_service function.

parent 2e6fc893
......@@ -373,9 +373,7 @@ DWORD __cdecl svcctl_OpenServiceW(
return ERROR_INVALID_NAME;
scmdatabase_lock(manager->db);
entry = scmdatabase_find_service(manager->db, lpServiceName);
if (entry != NULL)
InterlockedIncrement(&entry->ref_count);
entry = grab_service(scmdatabase_find_service(manager->db, lpServiceName));
scmdatabase_unlock(manager->db);
if (entry == NULL)
......
......@@ -346,15 +346,13 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
break;
services_list = slist_new;
}
services_list[i] = service;
InterlockedIncrement(&service->ref_count);
i++;
services_list[i++] = grab_service(service);
}
}
size = i;
scmdatabase_unlock(db);
size = i;
for (i = 0; i < size; i++)
{
DWORD err;
......@@ -494,6 +492,13 @@ void release_process(struct process_entry *process)
scmdatabase_unlock(db);
}
struct service_entry *grab_service(struct service_entry *service)
{
if (service)
InterlockedIncrement(&service->ref_count);
return service;
}
void release_service(struct service_entry *service)
{
struct scmdatabase *db = service->db;
......
......@@ -84,6 +84,7 @@ BOOL validate_service_name(LPCWSTR name);
BOOL validate_service_config(struct service_entry *entry);
DWORD save_service_config(struct service_entry *entry);
void free_service_entry(struct service_entry *entry);
struct service_entry *grab_service(struct service_entry *service);
void release_service(struct service_entry *service);
void service_lock(struct service_entry *service);
void service_unlock(struct service_entry *service);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment