Commit 8d540ec7 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

schedsvc: Add support for running missed tasks at the service start.

parent ae794549
......@@ -1039,6 +1039,30 @@ void check_task_time(void)
LeaveCriticalSection(&at_job_list_section);
}
void check_missed_task_time(void)
{
FILETIME current_ft, last_ft;
struct job_t *job;
GetSystemTimeAsFileTime(&current_ft);
FileTimeToLocalFileTime(&current_ft, &current_ft);
EnterCriticalSection(&at_job_list_section);
LIST_FOR_EACH_ENTRY(job, &at_job_list, struct job_t, entry)
{
if (SystemTimeToFileTime(&job->data.last_runtime, &last_ft))
{
if (job_runs_at(job, &last_ft, &current_ft))
{
run_job(job);
}
}
}
LeaveCriticalSection(&at_job_list_section);
}
void remove_job(const WCHAR *name)
{
struct job_t *job;
......
......@@ -31,6 +31,7 @@ void update_process_status(DWORD pid) DECLSPEC_HIDDEN;
BOOL get_next_runtime(LARGE_INTEGER *rt) DECLSPEC_HIDDEN;
void check_task_time(void) DECLSPEC_HIDDEN;
void load_at_tasks(void) DECLSPEC_HIDDEN;
void check_missed_task_time(void) DECLSPEC_HIDDEN;
static inline WCHAR *heap_strdupW(const WCHAR *src)
{
......
......@@ -54,6 +54,7 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
TRACE("Starting...\n");
load_at_tasks();
check_missed_task_time();
htimer = CreateWaitableTimerW(NULL, FALSE, NULL);
if (htimer == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment