1 Index: src/dird/getmsg.c
2 ===================================================================
3 --- src/dird/getmsg.c (révision 4696)
4 +++ src/dird/getmsg.c (copie de travail)
7 static char OK_msg[] = "1000 OK\n";
10 +void set_jcr_sd_job_status(JCR *jcr, int SDJobStatus)
12 + bool set_waittime=false;
13 + Dmsg2(800, "set_jcr_sd_job_status(%s, %c)\n", jcr->Job, SDJobStatus);
14 + /* if wait state is new, we keep current time for watchdog MaxWaitTime */
15 + switch (SDJobStatus) {
18 + case JS_WaitMaxJobs:
19 + set_waittime = true;
24 + if (job_waiting(jcr)) {
25 + set_waittime = false;
29 + /* set it before JobStatus */
30 + Dmsg0(800, "Setting wait_time\n");
31 + jcr->wait_time = time(NULL);
33 + jcr->SDJobStatus = SDJobStatus;
38 * Call appropriate processing routine
41 char Job[MAX_NAME_LENGTH];
42 if (sscanf(bs->msg, Job_status, &Job, &JobStatus) == 2) {
43 - jcr->SDJobStatus = JobStatus; /* current status */
44 + set_jcr_sd_job_status(jcr,JobStatus); /* current status */
46 Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
49 ===================================================================
50 --- src/dird/job.c (révision 4696)
51 +++ src/dird/job.c (copie de travail)
53 static void *job_thread(void *arg);
54 static void job_monitor_watchdog(watchdog_t *self);
55 static void job_monitor_destructor(watchdog_t *self);
56 -static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr);
57 -static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr);
58 +static bool job_check_maxwaittime(JCR *jcr);
59 +static bool job_check_maxruntime(JCR *jcr);
60 +static bool job_check_maxschedruntime(JCR *jcr);
62 /* Imported subroutines */
63 extern void term_scheduler();
65 Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n"));
68 + if (job_check_maxschedruntime(jcr)) {
69 + set_jcr_job_status(jcr, JS_Canceled);
70 + Jmsg(jcr, M_FATAL, 0, _("Job canceled because max sched run time exceeded.\n"));
73 /* TODO : check if it is used somewhere */
74 if (jcr->job->RunScripts == NULL) {
75 Dmsg0(200, "Warning, job->RunScripts is empty\n");
79 /* check MaxWaitTime */
80 - if (job_check_maxwaittime(control_jcr, jcr)) {
81 + if (job_check_maxwaittime(jcr)) {
82 set_jcr_job_status(jcr, JS_Canceled);
83 Jmsg(jcr, M_FATAL, 0, _("Max wait time exceeded. Job canceled.\n"));
85 /* check MaxRunTime */
86 - } else if (job_check_maxruntime(control_jcr, jcr)) {
87 + } else if (job_check_maxruntime(jcr)) {
88 set_jcr_job_status(jcr, JS_Canceled);
89 Jmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n"));
91 + /* check MaxSchedRunTime */
92 + } else if (job_check_maxschedruntime(jcr)) {
93 + set_jcr_job_status(jcr, JS_Canceled);
94 + Jmsg(jcr, M_FATAL, 0, _("Max sched run time exceeded. Job canceled.\n"));
100 * Check if the maxwaittime has expired and it is possible
103 -static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
104 +static bool job_check_maxwaittime(JCR *jcr)
109 - if (job_canceled(jcr)) {
110 - return false; /* already canceled */
111 + if (!job_waiting(jcr)) {
114 if (job->MaxWaitTime == 0 && job->FullMaxWaitTime == 0 &&
115 job->IncMaxWaitTime == 0 && job->DiffMaxWaitTime == 0) {
118 + Dmsg3(20, "check maxwaittime %u - %u >= %u\n", watchdog_time, jcr->wait_time, job->MaxWaitTime);
119 if (jcr->JobLevel == L_FULL && job->FullMaxWaitTime != 0 &&
120 - (watchdog_time - jcr->start_time) >= job->FullMaxWaitTime) {
121 + (watchdog_time - jcr->wait_time) >= job->FullMaxWaitTime) {
123 } else if (jcr->JobLevel == L_DIFFERENTIAL && job->DiffMaxWaitTime != 0 &&
124 - (watchdog_time - jcr->start_time) >= job->DiffMaxWaitTime) {
125 + (watchdog_time - jcr->wait_time) >= job->DiffMaxWaitTime) {
127 } else if (jcr->JobLevel == L_INCREMENTAL && job->IncMaxWaitTime != 0 &&
128 - (watchdog_time - jcr->start_time) >= job->IncMaxWaitTime) {
129 + (watchdog_time - jcr->wait_time) >= job->IncMaxWaitTime) {
131 } else if (job->MaxWaitTime != 0 &&
132 - (watchdog_time - jcr->start_time) >= job->MaxWaitTime) {
133 + (watchdog_time - jcr->wait_time) >= job->MaxWaitTime) {
138 * Check if maxruntime has expired and if the job can be
141 -static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
142 +static bool job_check_maxruntime(JCR *jcr)
144 if (jcr->job->MaxRunTime == 0 || job_canceled(jcr)) {
150 + * Check if MaxSchedRunTime has expired and if the job can be
153 +static bool job_check_maxschedruntime(JCR *jcr)
155 + if (jcr->job->MaxSchedRunTime == 0 || job_canceled(jcr)) {
158 + if ((watchdog_time - jcr->sched_time) < jcr->job->MaxSchedRunTime) {
159 + Dmsg3(200, "Job %p (%s) with MaxSchedRunTime %d not expired\n",
160 + jcr, jcr->Job, jcr->job->MaxSchedRunTime);
168 * Get or create a Pool record with the given name.
169 * Returns: 0 on error
171 Index: src/dird/dird_conf.c
172 ===================================================================
173 --- src/dird/dird_conf.c (révision 4696)
174 +++ src/dird/dird_conf.c (copie de travail)
176 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
177 {"writeverifylist",store_dir, ITEM(res_job.WriteVerifyList), 0, 0, 0},
178 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
179 + {"maxschedruntime", store_time, ITEM(res_job.MaxSchedRunTime), 0, 0, 0},
180 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
181 {"fullmaxwaittime", store_time, ITEM(res_job.FullMaxWaitTime), 0, 0, 0},
182 {"incrementalmaxwaittime", store_time, ITEM(res_job.IncMaxWaitTime), 0, 0, 0},
184 if (res->res_job.WriteBootstrap) {
185 sendit(sock, _(" --> WriteBootstrap=%s\n"), NPRT(res->res_job.WriteBootstrap));
187 + if (res->res_job.MaxRunTime) {
188 + sendit(sock, _(" --> MaxRunTime=%u\n"), res->res_job.MaxRunTime);
190 + if (res->res_job.MaxWaitTime) {
191 + sendit(sock, _(" --> MaxWaitTime=%u\n"), res->res_job.MaxWaitTime);
193 + if (res->res_job.MaxStartDelay) {
194 + sendit(sock, _(" --> MaxStartDelay=%u\n"), res->res_job.MaxStartDelay);
196 if (res->res_job.storage) {
198 foreach_alist(store, res->res_job.storage) {
199 Index: src/dird/dird_conf.h
200 ===================================================================
201 --- src/dird/dird_conf.h (révision 4696)
202 +++ src/dird/dird_conf.h (copie de travail)
204 char *WriteVerifyList; /* List of changed files */
206 int replace; /* How (overwrite, ..) */
207 + utime_t MaxSchedRunTime; /* max run time in seconds from Scheduled time*/
208 utime_t MaxRunTime; /* max run time in seconds */
209 utime_t MaxWaitTime; /* max blocking time in seconds */
210 utime_t FullMaxWaitTime; /* Max Full job wait time */
212 ===================================================================
213 --- src/jcr.h (révision 4696)
214 +++ src/jcr.h (copie de travail)
216 jcr->JobStatus == JS_ErrorTerminated || \
217 jcr->JobStatus == JS_FatalError)
219 +#define job_waiting(jcr) \
220 + (jcr->JobStatus == JS_WaitFD || \
221 + jcr->JobStatus == JS_WaitSD || \
222 + jcr->JobStatus == JS_WaitMedia || \
223 + jcr->JobStatus == JS_WaitMount || \
224 + jcr->JobStatus == JS_WaitStoreRes || \
225 + jcr->JobStatus == JS_WaitJobRes || \
226 + jcr->JobStatus == JS_WaitClientRes|| \
227 + jcr->JobStatus == JS_WaitMaxJobs || \
228 + jcr->JobStatus == JS_WaitPriority || \
229 + jcr->SDJobStatus == JS_WaitMedia || \
230 + jcr->SDJobStatus == JS_WaitMount || \
231 + jcr->SDJobStatus == JS_WaitMaxJobs)
235 #define foreach_jcr(jcr) \
236 for (jcr=jcr_walk_start(); jcr; (jcr=jcr_walk_next(jcr)) )
239 time_t start_time; /* when job actually started */
240 time_t run_time; /* used for computing speed */
241 time_t end_time; /* job end time */
242 + time_t wait_time; /* when job have started to wait */
243 POOLMEM *client_name; /* client name */
244 POOLMEM *RestoreBootstrap; /* Bootstrap file to restore */
245 POOLMEM *stime; /* start time for incremental/differential */
247 ===================================================================
248 --- src/lib/jcr.c (révision 4696)
249 +++ src/lib/jcr.c (copie de travail)
250 @@ -546,18 +546,54 @@
252 void set_jcr_job_status(JCR *jcr, int JobStatus)
254 + bool set_waittime=false;
255 + Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
256 + /* if wait state is new, we keep current time for watchdog MaxWaitTime */
257 + switch (JobStatus) {
262 + case JS_WaitStoreRes:
263 + case JS_WaitJobRes:
264 + case JS_WaitClientRes:
265 + case JS_WaitMaxJobs:
266 + case JS_WaitPriority:
267 + set_waittime = true;
272 + switch (jcr->JobStatus) {
274 * For a set of errors, ... keep the current status
275 * so it isn't lost. For all others, set it.
277 - switch (jcr->JobStatus) {
278 case JS_ErrorTerminated:
285 + * For a set of Wait situation, keep old time.
291 + case JS_WaitStoreRes:
292 + case JS_WaitJobRes:
293 + case JS_WaitClientRes:
294 + case JS_WaitMaxJobs:
295 + case JS_WaitPriority:
296 + set_waittime = false; /* keep old time */
298 + if (set_waittime) {
299 + /* set it before JobStatus */
300 + Dmsg0(800, "Setting wait_time\n");
301 + jcr->wait_time = time(NULL);
303 jcr->JobStatus = JobStatus;