mirror of
https://github.com/reactos/wine.git
synced 2024-12-14 07:08:41 +00:00
services: Hold startup lock before calling service_start.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
36ccc45db6
commit
4c01feb714
@ -1071,8 +1071,12 @@ DWORD __cdecl svcctl_StartServiceW(
|
||||
if (service->service_entry->config.dwStartType == SERVICE_DISABLED)
|
||||
return ERROR_SERVICE_DISABLED;
|
||||
|
||||
if (!scmdatabase_lock_startup(service->service_entry->db))
|
||||
return ERROR_SERVICE_DATABASE_LOCKED;
|
||||
|
||||
err = service_start(service->service_entry, dwNumServiceArgs, lpServiceArgVectors);
|
||||
|
||||
scmdatabase_unlock_startup(service->service_entry->db);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1226,9 +1230,8 @@ DWORD __cdecl svcctl_LockServiceDatabase(
|
||||
if ((err = validate_scm_handle(hSCManager, SC_MANAGER_LOCK, &manager)) != ERROR_SUCCESS)
|
||||
return err;
|
||||
|
||||
err = scmdatabase_lock_startup(manager->db);
|
||||
if (err != ERROR_SUCCESS)
|
||||
return err;
|
||||
if (!scmdatabase_lock_startup(manager->db))
|
||||
return ERROR_SERVICE_DATABASE_LOCKED;
|
||||
|
||||
lock = HeapAlloc(GetProcessHeap(), 0, sizeof(struct sc_lock));
|
||||
if (!lock)
|
||||
|
@ -352,6 +352,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
|
||||
size = i;
|
||||
|
||||
scmdatabase_unlock(db);
|
||||
while (!scmdatabase_lock_startup(db)) Sleep(10);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
@ -364,6 +365,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
|
||||
release_service(service);
|
||||
}
|
||||
|
||||
scmdatabase_unlock_startup(db);
|
||||
HeapFree(GetProcessHeap(), 0, services_list);
|
||||
}
|
||||
|
||||
@ -608,11 +610,9 @@ static DWORD scmdatabase_load_services(struct scmdatabase *db)
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
DWORD scmdatabase_lock_startup(struct scmdatabase *db)
|
||||
BOOL scmdatabase_lock_startup(struct scmdatabase *db)
|
||||
{
|
||||
if (InterlockedCompareExchange(&db->service_start_lock, TRUE, FALSE))
|
||||
return ERROR_SERVICE_DATABASE_LOCKED;
|
||||
return ERROR_SUCCESS;
|
||||
return !InterlockedCompareExchange(&db->service_start_lock, TRUE, FALSE);
|
||||
}
|
||||
|
||||
void scmdatabase_unlock_startup(struct scmdatabase *db)
|
||||
@ -904,10 +904,6 @@ DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *
|
||||
struct process_entry *process = NULL;
|
||||
DWORD err;
|
||||
|
||||
err = scmdatabase_lock_startup(service->db);
|
||||
if (err != ERROR_SUCCESS)
|
||||
return err;
|
||||
|
||||
err = service_start_process(service, &process);
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
@ -928,10 +924,7 @@ DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *
|
||||
release_process(process);
|
||||
}
|
||||
|
||||
scmdatabase_unlock_startup(service->db);
|
||||
|
||||
WINE_TRACE("returning %d\n", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ struct service_entry *scmdatabase_find_service(struct scmdatabase *db, LPCWSTR n
|
||||
struct service_entry *scmdatabase_find_service_by_displayname(struct scmdatabase *db, LPCWSTR name);
|
||||
DWORD scmdatabase_add_service(struct scmdatabase *db, struct service_entry *entry);
|
||||
|
||||
DWORD scmdatabase_lock_startup(struct scmdatabase *db);
|
||||
BOOL scmdatabase_lock_startup(struct scmdatabase *db);
|
||||
void scmdatabase_unlock_startup(struct scmdatabase *db);
|
||||
|
||||
void scmdatabase_lock(struct scmdatabase *db);
|
||||
|
Loading…
Reference in New Issue
Block a user