Alexandre Julliard : schedsvc: Only restart the directory watch once we' ve received data.
Alexandre Julliard
julliard at winehq.org
Tue Jun 26 15:43:10 CDT 2018
Module: wine
Branch: master
Commit: 6a1ce3c114b1e1fa94bedd270299d127680f6d33
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6a1ce3c114b1e1fa94bedd270299d127680f6d33
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Jun 26 13:09:13 2018 +0200
schedsvc: Only restart the directory watch once we've received data.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/schedsvc/svc_main.c | 47 +++++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/dlls/schedsvc/svc_main.c b/dlls/schedsvc/svc_main.c
index 8e23a04..8830d59 100644
--- a/dlls/schedsvc/svc_main.c
+++ b/dlls/schedsvc/svc_main.c
@@ -47,9 +47,17 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
WCHAR path[MAX_PATH];
HANDLE htasks, hport, htimer;
- JOBOBJECT_ASSOCIATE_COMPLETION_PORT info;
+ JOBOBJECT_ASSOCIATE_COMPLETION_PORT job_info;
OVERLAPPED ov;
LARGE_INTEGER period;
+ struct
+ {
+ FILE_NOTIFY_INFORMATION data;
+ WCHAR name_buffer[MAX_PATH];
+ } info;
+
+ /* the buffer must be DWORD aligned */
+ C_ASSERT(!(sizeof(info) & 3));
TRACE("Starting...\n");
@@ -91,9 +99,9 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
return -1;
}
- info.CompletionKey = hjob_queue;
- info.CompletionPort = hport;
- if (!SetInformationJobObject(hjob_queue, JobObjectAssociateCompletionPortInformation, &info, sizeof(info)))
+ job_info.CompletionKey = hjob_queue;
+ job_info.CompletionPort = hport;
+ if (!SetInformationJobObject(hjob_queue, JobObjectAssociateCompletionPortInformation, &job_info, sizeof(job_info)))
{
ERR("SetInformationJobObject failed\n");
return -1;
@@ -102,29 +110,16 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
memset(&ov, 0, sizeof(ov));
ov.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ memset(&info, 0, sizeof(info));
+ ReadDirectoryChangesW(htasks, &info, sizeof(info), FALSE,
+ FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
+ NULL, &ov, NULL);
+
for (;;)
{
- struct
- {
- FILE_NOTIFY_INFORMATION data;
- WCHAR name_buffer[MAX_PATH];
- } info;
HANDLE events[4];
DWORD ret;
- /* the buffer must be DWORD aligned */
- C_ASSERT(!(sizeof(info) & 3));
-
- memset(&info, 0, sizeof(info));
-
- ret = ReadDirectoryChangesW(htasks, &info, sizeof(info), FALSE,
- FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
- NULL, &ov, NULL);
- if (!ret) break;
-
- if (info.data.NextEntryOffset)
- FIXME("got multiple entries\n");
-
events[0] = done_event;
events[1] = htimer;
events[2] = hport;
@@ -160,6 +155,9 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
continue;
}
+ if (info.data.NextEntryOffset)
+ FIXME("got multiple entries\n");
+
/* Directory change notification */
info.data.FileName[info.data.FileNameLength/sizeof(WCHAR)] = 0;
@@ -204,6 +202,11 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
if (!SetWaitableTimer(htimer, &period, 0, NULL, NULL, FALSE))
ERR("SetWaitableTimer failed\n");
}
+
+ memset(&info, 0, sizeof(info));
+ if (!ReadDirectoryChangesW(htasks, &info, sizeof(info), FALSE,
+ FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
+ NULL, &ov, NULL)) break;
}
CancelWaitableTimer(htimer);
More information about the wine-cvs
mailing list