services: Use threadpool timers for services delay loading.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47675 Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
deb26091ef
commit
765815729f
|
@ -353,37 +353,34 @@ static void CALLBACK delayed_autostart_cancel_callback(void *object, void *userd
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CALLBACK delayed_autostart_callback(TP_CALLBACK_INSTANCE *instance, void *context,
|
static void CALLBACK delayed_autostart_callback(TP_CALLBACK_INSTANCE *instance, void *context,
|
||||||
TP_WAIT *wait, TP_WAIT_RESULT result)
|
TP_TIMER *timer)
|
||||||
{
|
{
|
||||||
struct delayed_autostart_params *params = context;
|
struct delayed_autostart_params *params = context;
|
||||||
struct service_entry *service;
|
struct service_entry *service;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
DWORD err;
|
DWORD err;
|
||||||
|
|
||||||
if (result == WAIT_TIMEOUT)
|
scmdatabase_lock_startup(active_database, INFINITE);
|
||||||
|
|
||||||
|
for (i = 0; i < params->count; i++)
|
||||||
{
|
{
|
||||||
scmdatabase_lock_startup(active_database, INFINITE);
|
service = params->services[i];
|
||||||
|
if (service->status.dwCurrentState == SERVICE_STOPPED)
|
||||||
for (i = 0; i < params->count; i++)
|
|
||||||
{
|
{
|
||||||
service = params->services[i];
|
TRACE("Starting delayed auto-start service %s\n", debugstr_w(service->name));
|
||||||
if (service->status.dwCurrentState == SERVICE_STOPPED)
|
err = service_start(service, 0, NULL);
|
||||||
{
|
if (err != ERROR_SUCCESS)
|
||||||
TRACE("Starting deleyed auto-start service %s\n", debugstr_w(service->name));
|
FIXME("Delayed auto-start service %s failed to start: %d\n",
|
||||||
err = service_start(service, 0, NULL);
|
wine_dbgstr_w(service->name), err);
|
||||||
if (err != ERROR_SUCCESS)
|
|
||||||
FIXME("Delayed auto-start service %s failed to start: %d\n",
|
|
||||||
wine_dbgstr_w(service->name), err);
|
|
||||||
}
|
|
||||||
release_service(service);
|
|
||||||
}
|
}
|
||||||
|
release_service(service);
|
||||||
scmdatabase_unlock_startup(active_database);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scmdatabase_unlock_startup(active_database);
|
||||||
|
|
||||||
heap_free(params->services);
|
heap_free(params->services);
|
||||||
heap_free(params);
|
heap_free(params);
|
||||||
CloseThreadpoolWait(wait);
|
CloseThreadpoolTimer(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL schedule_delayed_autostart(struct service_entry **services, unsigned int count)
|
static BOOL schedule_delayed_autostart(struct service_entry **services, unsigned int count)
|
||||||
|
@ -391,7 +388,7 @@ static BOOL schedule_delayed_autostart(struct service_entry **services, unsigned
|
||||||
struct delayed_autostart_params *params;
|
struct delayed_autostart_params *params;
|
||||||
TP_CALLBACK_ENVIRON environment;
|
TP_CALLBACK_ENVIRON environment;
|
||||||
LARGE_INTEGER timestamp;
|
LARGE_INTEGER timestamp;
|
||||||
TP_WAIT *wait;
|
TP_TIMER *timer;
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
|
||||||
if (!(delayed_autostart_cleanup = CreateThreadpoolCleanupGroup()))
|
if (!(delayed_autostart_cleanup = CreateThreadpoolCleanupGroup()))
|
||||||
|
@ -413,14 +410,14 @@ static BOOL schedule_delayed_autostart(struct service_entry **services, unsigned
|
||||||
ft.dwLowDateTime = timestamp.u.LowPart;
|
ft.dwLowDateTime = timestamp.u.LowPart;
|
||||||
ft.dwHighDateTime = timestamp.u.HighPart;
|
ft.dwHighDateTime = timestamp.u.HighPart;
|
||||||
|
|
||||||
if (!(wait = CreateThreadpoolWait(delayed_autostart_callback, params, &environment)))
|
if (!(timer = CreateThreadpoolTimer(delayed_autostart_callback, params, &environment)))
|
||||||
{
|
{
|
||||||
ERR("CreateThreadpoolWait failed: %u\n", GetLastError());
|
ERR("CreateThreadpoolWait failed: %u\n", GetLastError());
|
||||||
heap_free(params);
|
heap_free(params);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetThreadpoolWait(wait, params, &ft);
|
SetThreadpoolTimer(timer, &ft, 0, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue