[SCHEDSVC] Improvements to the scheduler service

Use WaitForMultipleObjects in the mail scheduler loop:
- Use events to signal service stop and job update events to the main loop.
- Use the timeout timer to start the next job.
This commit is contained in:
Eric Kohl 2018-10-28 00:02:18 +02:00
parent 03294dd097
commit e4d79e514a
4 changed files with 108 additions and 32 deletions

View file

@ -112,8 +112,6 @@ NetrJobAdd(
pJob->JobId = dwNextJobId++;
dwJobCount++;
// Cancel the start timer
/* Append the new job to the job list */
InsertTailList(&JobListHead, &pJob->JobEntry);
@ -129,11 +127,13 @@ NetrJobAdd(
DumpStartList(&StartListHead);
#endif
// Update the start timer
/* Release the job list lock */
RtlReleaseResource(&JobListLock);
/* Set the update event */
if (Events[1] != NULL)
SetEvent(Events[1]);
/* Return the new job ID */
*pJobId = pJob->JobId;
@ -162,8 +162,6 @@ NetrJobDel(
/* Acquire the job list lock exclusively */
RtlAcquireResourceExclusive(&JobListLock, TRUE);
// Cancel the start timer
JobEntry = JobListHead.Flink;
while (JobEntry != &JobListHead)
{
@ -193,11 +191,13 @@ NetrJobDel(
JobEntry = JobEntry->Flink;
}
// Update the start timer
/* Release the job list lock */
RtlReleaseResource(&JobListLock);
/* Set the update event */
if (Events[1] != NULL)
SetEvent(Events[1]);
return ERROR_SUCCESS;
}