From c85bc14d55e0f75de1591cf2b0f50c36898c9cb0 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 17 Apr 2018 15:12:08 +0800 Subject: [PATCH] schedsvc: Remove job from the list when job file is deleted. Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/schedsvc/atsvc.c | 28 ++++++++++++++++++++++++++++ dlls/schedsvc/schedsvc_private.h | 1 + dlls/schedsvc/svc_main.c | 8 ++++++++ 3 files changed, 37 insertions(+) diff --git a/dlls/schedsvc/atsvc.c b/dlls/schedsvc/atsvc.c index baa808a97b6..7b1c60b8fe0 100644 --- a/dlls/schedsvc/atsvc.c +++ b/dlls/schedsvc/atsvc.c @@ -327,6 +327,34 @@ void add_job(const WCHAR *name) } } +static struct job_t *find_job(DWORD jobid, const WCHAR *name) +{ + struct job_t *job; + + LIST_FOR_EACH_ENTRY(job, &at_job_list, struct job_t, entry) + { + if ((name && !lstrcmpiW(job->name, name)) || job->info.JobId == jobid) + return job; + } + + return NULL; +} + +void remove_job(const WCHAR *name) +{ + struct job_t *job; + + EnterCriticalSection(&at_job_list_section); + job = find_job(0, name); + if (job) + { + list_remove(&job->entry); + heap_free(job->name); + heap_free(job); + } + LeaveCriticalSection(&at_job_list_section); +} + DWORD __cdecl NetrJobAdd(ATSVC_HANDLE server_name, AT_INFO *info, DWORD *jobid) { FIXME("%s,%p,%p: stub\n", debugstr_w(server_name), info, jobid); diff --git a/dlls/schedsvc/schedsvc_private.h b/dlls/schedsvc/schedsvc_private.h index 1e5d575d70a..215bba003eb 100644 --- a/dlls/schedsvc/schedsvc_private.h +++ b/dlls/schedsvc/schedsvc_private.h @@ -24,6 +24,7 @@ void schedsvc_auto_start(void) DECLSPEC_HIDDEN; void add_job(const WCHAR *name) DECLSPEC_HIDDEN; +void remove_job(const WCHAR *name) DECLSPEC_HIDDEN; static inline WCHAR *heap_strdupW(const WCHAR *src) { diff --git a/dlls/schedsvc/svc_main.c b/dlls/schedsvc/svc_main.c index 0835d71b427..1ccc34529be 100644 --- a/dlls/schedsvc/svc_main.c +++ b/dlls/schedsvc/svc_main.c @@ -91,6 +91,14 @@ static DWORD WINAPI tasks_monitor_thread(void *arg) add_job(path); break; + case FILE_ACTION_REMOVED: + TRACE("FILE_ACTION_REMOVED %s\n", debugstr_w(info.data.FileName)); + GetWindowsDirectoryW(path, MAX_PATH); + lstrcatW(path, tasksW); + lstrcatW(path, info.data.FileName); + remove_job(path); + break; + default: FIXME("%s: action %#x not handled\n", debugstr_w(info.data.FileName), info.data.Action); break;