]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/maxschedruntime.patch
07af424660a71361f64aa791cbbe036fb7f3ea95
[bacula/bacula] / bacula / patches / testing / maxschedruntime.patch
1 Index: src/dird/job.c
2 ===================================================================
3 --- src/dird/job.c      (révision 4696)
4 +++ src/dird/job.c      (copie de travail)
5 @@ -43,6 +43,7 @@
6  static void job_monitor_destructor(watchdog_t *self);
7  static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr);
8  static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr);
9 +static bool job_check_maxschedruntime(JCR *control_jcr, JCR *jcr);
10  
11  /* Imported subroutines */
12  extern void term_scheduler();
13 @@ -459,7 +460,11 @@
14           set_jcr_job_status(jcr, JS_Canceled);
15           Jmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n"));
16           cancel = true;
17 -      }
18 +      /* check MaxSchedRunTime */ 
19 +      } else if (job_check_maxschedruntime(control_jcr, jcr)) {
20 +         set_jcr_job_status(jcr, JS_Canceled);
21 +         Jmsg(jcr, M_FATAL, 0, _("Max sched run time exceeded. Job canceled.\n"));
22 +         cancel = true;
23  
24        if (cancel) {
25           Dmsg3(800, "Cancelling JCR %p jobid %d (%s)\n", jcr, jcr->JobId, jcr->Job);
26 @@ -527,6 +533,24 @@
27  }
28  
29  /*
30 + * Check if MaxSchedRunTime has expired and if the job can be
31 + *   canceled.
32 + */
33 +static bool job_check_maxschedruntime(JCR *control_jcr, JCR *jcr)
34 +{
35 +   if (jcr->job->MaxSchedRunTime == 0 || job_canceled(jcr)) {
36 +      return false;
37 +   }
38 +   if ((watchdog_time - jcr->sched_time) < jcr->job->MaxSchedRunTime) {
39 +      Dmsg3(200, "Job %p (%s) with MaxSchedRunTime %d not expired\n",
40 +            jcr, jcr->Job, jcr->job->MaxSchedRunTime);
41 +      return false;
42 +   }
43 +
44 +   return true;
45 +}
46 +
47 +/*
48   * Get or create a Pool record with the given name.
49   * Returns: 0 on error
50   *          poolid if OK
51 Index: src/dird/dird_conf.c
52 ===================================================================
53 --- src/dird/dird_conf.c        (révision 4696)
54 +++ src/dird/dird_conf.c        (copie de travail)
55 @@ -281,6 +281,7 @@
56     {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
57     {"writeverifylist",store_dir, ITEM(res_job.WriteVerifyList), 0, 0, 0},
58     {"replace",  store_replace,  ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
59 +   {"maxschedruntime", store_time, ITEM(res_job.MaxSchedRunTime), 0, 0, 0},
60     {"maxruntime",   store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
61     {"fullmaxwaittime",  store_time, ITEM(res_job.FullMaxWaitTime), 0, 0, 0},
62     {"incrementalmaxwaittime",  store_time, ITEM(res_job.IncMaxWaitTime), 0, 0, 0},
63 Index: src/dird/dird_conf.h
64 ===================================================================
65 --- src/dird/dird_conf.h        (révision 4696)
66 +++ src/dird/dird_conf.h        (copie de travail)
67 @@ -371,6 +371,7 @@
68        char *WriteVerifyList;          /* List of changed files */
69     };
70     int   replace;                     /* How (overwrite, ..) */
71 +   utime_t MaxSchedRunTime;           /* max run time in seconds from Scheduled time*/
72     utime_t MaxRunTime;                /* max run time in seconds */
73     utime_t MaxWaitTime;               /* max blocking time in seconds */
74     utime_t FullMaxWaitTime;           /* Max Full job wait time */