static void scmdatabase_wait_terminate(struct scmdatabase *db) { struct service_entry *service; BOOL run = TRUE; scmdatabase_lock_shared(db); while(run) { run = FALSE; LIST_FOR_EACH_ENTRY(service, &db->services, struct service_entry, entry) { if(service->process) { scmdatabase_unlock(db); WaitForSingleObject(service->process, INFINITE); scmdatabase_lock_shared(db); CloseHandle(service->process); service->process = NULL; run = TRUE; break; } } } scmdatabase_unlock(db); }
static void scmdatabase_autostart_services(struct scmdatabase *db) { struct service_entry **services_list; unsigned int i = 0; unsigned int size = 32; struct service_entry *service; services_list = HeapAlloc(GetProcessHeap(), 0, size * sizeof(services_list[0])); if (!services_list) return; scmdatabase_lock_shared(db); LIST_FOR_EACH_ENTRY(service, &db->services, struct service_entry, entry) { if (service->config.dwStartType == SERVICE_BOOT_START || service->config.dwStartType == SERVICE_SYSTEM_START || service->config.dwStartType == SERVICE_AUTO_START) { if (i+1 >= size) { struct service_entry **slist_new; size *= 2; slist_new = HeapReAlloc(GetProcessHeap(), 0, services_list, size * sizeof(services_list[0])); if (!slist_new) break; services_list = slist_new; } services_list[i] = service; service->ref_count++; i++; } } scmdatabase_unlock(db); size = i; for (i = 0; i < size; i++) { DWORD err; const WCHAR *argv[2]; service = services_list[i]; argv[0] = service->name; argv[1] = NULL; err = service_start(service, 1, argv); if (err != ERROR_SUCCESS) WINE_FIXME("Auto-start service %s failed to start: %d\n", wine_dbgstr_w(service->name), err); release_service(service); } HeapFree(GetProcessHeap(), 0, services_list); }