Module: wine Branch: master Commit: 8f07e6932b23acf5a3233dc55bbe7a426f35fc28 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8f07e6932b23acf5a3233dc55b...
Author: Rob Shearman robertshearman@gmail.com Date: Tue Mar 24 11:25:35 2009 +0000
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.
---
programs/services/rpc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/programs/services/rpc.c b/programs/services/rpc.c index 7c09f55..22391c2 100644 --- a/programs/services/rpc.c +++ b/programs/services/rpc.c @@ -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;