Commit 8f07e693 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

services: Add a ref count to the service entry in svcctl_CreateServiceW.

The ref count will be released by SC_RPC_HANDLE_destroy when the returned handle is destroyed. Change svcctl_OpenServiceW to use InterlockedIncrement to increment the ref count since the service is in the database and therefore could be shared and SC_RPC_HANDLE_destroy doesn't take the scmdatabase lock when decrementing the ref count.
parent 6789fa85
......@@ -309,7 +309,7 @@ DWORD svcctl_OpenServiceW(
scmdatabase_lock_shared(manager->db);
entry = scmdatabase_find_service(manager->db, lpServiceName);
if (entry != NULL)
entry->ref_count++;
InterlockedIncrement(&entry->ref_count);
scmdatabase_unlock(manager->db);
if (entry == NULL)
......@@ -358,6 +358,7 @@ DWORD svcctl_CreateServiceW(
err = service_create(lpServiceName, &entry);
if (err != ERROR_SUCCESS)
return err;
entry->ref_count = 1;
entry->config.dwServiceType = entry->status.dwServiceType = dwServiceType;
entry->config.dwStartType = dwStartType;
entry->config.dwErrorControl = dwErrorControl;
......
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