Author: ekohl
Date: Sun Apr 9 08:47:10 2017
New Revision: 74288
URL:
http://svn.reactos.org/svn/reactos?rev=74288&view=rev
Log:
[SCHEDSVC]
Implement storing and loading of jobs in the registry.
Modified:
trunk/reactos/base/services/schedsvc/CMakeLists.txt
trunk/reactos/base/services/schedsvc/precomp.h
trunk/reactos/base/services/schedsvc/rpcserver.c
trunk/reactos/base/services/schedsvc/schedsvc.c
Modified: trunk/reactos/base/services/schedsvc/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/schedsvc/CMa…
==============================================================================
--- trunk/reactos/base/services/schedsvc/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/services/schedsvc/CMakeLists.txt [iso-8859-1] Sun Apr 9 08:47:10
2017
@@ -4,6 +4,7 @@
spec2def(schedsvc.dll schedsvc.spec ADD_IMPORTLIB)
add_library(schedsvc SHARED
+ job.c
rpcserver.c
schedsvc.c
schedsvc.rc
Modified: trunk/reactos/base/services/schedsvc/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/schedsvc/pre…
==============================================================================
--- trunk/reactos/base/services/schedsvc/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/services/schedsvc/precomp.h [iso-8859-1] Sun Apr 9 08:47:10 2017
@@ -5,6 +5,7 @@
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <stdarg.h>
+#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
@@ -16,8 +17,55 @@
#include <wine/debug.h>
+NTSYSAPI
+ULONG
+NTAPI
+RtlRandomEx(
+ PULONG Seed);
+
+typedef struct _JOB
+{
+ LIST_ENTRY JobEntry;
+
+ LIST_ENTRY StartEntry;
+ LARGE_INTEGER StartTime;
+ WCHAR Name[9];
+
+ DWORD JobId;
+ DWORD_PTR JobTime;
+ DWORD DaysOfMonth;
+ UCHAR DaysOfWeek;
+ UCHAR Flags;
+ WCHAR Command[1];
+} JOB, *PJOB;
+
+#define DWORD_MAX 0xffffffffUL
+
+extern DWORD dwNextJobId;
+extern DWORD dwJobCount;
+
extern LIST_ENTRY JobListHead;
extern RTL_RESOURCE JobListLock;
+
+extern LIST_ENTRY StartListHead;
+extern RTL_RESOURCE StartListLock;
+
+
+/* job.c */
+
+LONG
+SaveJob(
+ PJOB pJob);
+
+LONG
+DeleteJob(
+ PJOB pJob);
+
+LONG
+LoadJobs(VOID);
+
+
+/* rpcserver.c */
DWORD
WINAPI
Modified: trunk/reactos/base/services/schedsvc/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/schedsvc/rpc…
==============================================================================
--- trunk/reactos/base/services/schedsvc/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/schedsvc/rpcserver.c [iso-8859-1] Sun Apr 9 08:47:10
2017
@@ -32,25 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(schedsvc);
-#define DWORD_MAX 0xffffffffUL
-
-typedef struct _JOB
-{
- LIST_ENTRY Entry;
- DWORD JobId;
-
- DWORD_PTR JobTime;
- DWORD DaysOfMonth;
- UCHAR DaysOfWeek;
- UCHAR Flags;
- WCHAR Command[1];
-} JOB, *PJOB;
-
-DWORD dwNextJobId = 0;
-DWORD dwJobCount = 0;
-LIST_ENTRY JobListHead;
-RTL_RESOURCE JobListLock;
-
/* FUNCTIONS *****************************************************************/
@@ -132,10 +113,19 @@
dwJobCount++;
/* Append the new job to the job list */
- InsertTailList(&JobListHead, &pJob->Entry);
+ InsertTailList(&JobListHead, &pJob->JobEntry);
/* Release the job list lock */
RtlReleaseResource(&JobListLock);
+
+ /* Save the job in the registry */
+ SaveJob(pJob);
+
+ // Calculate start time
+
+ // Insert job into start list
+
+ // Update start timer
/* Return the new job ID */
*pJobId = pJob->JobId;
@@ -158,16 +148,27 @@
TRACE("NetrJobDel(%S %lu %lu)\n",
ServerName, MinJobId, MaxJobId);
+ /* Check the job IDs */
+ if (MinJobId > MaxJobId)
+ return ERROR_INVALID_PARAMETER;
+
/* Acquire the job list lock exclusively */
RtlAcquireResourceExclusive(&JobListLock, TRUE);
JobEntry = JobListHead.Flink;
while (JobEntry != &JobListHead)
{
- CurrentJob = CONTAINING_RECORD(JobEntry, JOB, Entry);
+ CurrentJob = CONTAINING_RECORD(JobEntry, JOB, JobEntry);
if ((CurrentJob->JobId >= MinJobId) && (CurrentJob->JobId <=
MaxJobId))
{
+ // Remove job from start list
+
+ // Update start timer
+
+ /* Remove the job from the registry */
+ DeleteJob(CurrentJob);
+
NextEntry = JobEntry->Flink;
if (RemoveEntryList(JobEntry))
{
@@ -234,7 +235,7 @@
JobEntry = JobListHead.Flink;
while (JobEntry != &JobListHead)
{
- CurrentJob = CONTAINING_RECORD(JobEntry, JOB, Entry);
+ CurrentJob = CONTAINING_RECORD(JobEntry, JOB, JobEntry);
if (dwIndex >= dwStartIndex)
{
@@ -275,7 +276,7 @@
JobEntry = JobListHead.Flink;
while (JobEntry != &JobListHead)
{
- CurrentJob = CONTAINING_RECORD(JobEntry, JOB, Entry);
+ CurrentJob = CONTAINING_RECORD(JobEntry, JOB, JobEntry);
if (dwIndex >= dwStartIndex)
{
@@ -342,7 +343,7 @@
JobEntry = JobListHead.Flink;
while (JobEntry != &JobListHead)
{
- CurrentJob = CONTAINING_RECORD(JobEntry, JOB, Entry);
+ CurrentJob = CONTAINING_RECORD(JobEntry, JOB, JobEntry);
/* Do we have the right job? */
if (CurrentJob->JobId == JobId)
Modified: trunk/reactos/base/services/schedsvc/schedsvc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/schedsvc/sch…
==============================================================================
--- trunk/reactos/base/services/schedsvc/schedsvc.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/schedsvc/schedsvc.c [iso-8859-1] Sun Apr 9 08:47:10 2017
@@ -21,7 +21,7 @@
* PROJECT: ReactOS Services
* FILE: base/services/schedsvc/schedsvc.c
* PURPOSE: Scheduling service
- * PROGRAMMER: Eric Kohl
+ * PROGRAMMER: Eric Kohl <eric.kohl(a)reactos.org>
*/
/* INCLUDES *****************************************************************/
@@ -99,6 +99,7 @@
case SERVICE_CONTROL_SHUTDOWN:
TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
UpdateServiceStatus(SERVICE_STOP_PENDING);
+ RpcMgmtStopServerListening(NULL);
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
@@ -114,6 +115,7 @@
ServiceInit(VOID)
{
HANDLE hThread;
+ DWORD dwError;
/* Initialize the job list */
InitializeListHead(&JobListHead);
@@ -121,6 +123,18 @@
/* Initialize the job list lock */
RtlInitializeResource(&JobListLock);
+ /* Initialize the start list */
+ InitializeListHead(&StartListHead);
+
+ /* Initialize the start list lock */
+ RtlInitializeResource(&StartListLock);
+
+ /* Load stored jobs from the registry */
+ dwError = LoadJobs();
+ if (dwError != ERROR_SUCCESS)
+ return dwError;
+
+ /* Start the RPC thread */
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)RpcThreadRoutine,