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.
This commit is contained in:
parent
6789fa8544
commit
8f07e6932b
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue