]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.0.3-scheduler-next-hour.patch
really fixed problem with ß
[bacula/bacula] / bacula / patches / 2.0.3-scheduler-next-hour.patch
1
2  This patch should fix bug #812 where the DST time shift was 
3  incorrectly handled. This patch was submitted by Martin Simmons.
4  Apply it to Bacula version 2.0.3 with:
5
6   cd <bacula-source>
7   patch -p0 <2.0.3-scheduler-next-hour.patch
8   make
9   ...
10   make install
11
12 Index: src/dird/scheduler.c
13 ===================================================================
14 --- src/dird/scheduler.c        (revision 4445)
15 +++ src/dird/scheduler.c        (working copy)
16 @@ -175,11 +175,11 @@
17        }
18        /* Recheck at least once per minute */
19        bmicrosleep((next_check_secs < twait)?next_check_secs:twait, 0);
20 -      /* Attempt to handle clock shift from/to daylight savings time
21 +      /* Attempt to handle clock shift (but not daylight savings time changes)
22         * we allow a skew of 10 seconds before invalidating everything.
23         */
24        now = time(NULL);
25 -      if (now < prev+10 || now > (prev+next_check_secs+10)) {
26 +      if (now < prev-10 || now > (prev+next_check_secs+10)) {
27           schedules_invalidated = true;
28        }
29     }
30 @@ -284,6 +284,9 @@
31     wom = mday / 7;
32     woy = tm_woy(now);                     /* get week of year */
33  
34 +   Dmsg7(dbglvl, "now = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
35 +        now, hour, month, mday, wday, wom, woy);
36 +
37     /*
38      * Compute values for next hour from now.
39      * We do this to be sure we don't miss a job while
40 @@ -299,6 +302,9 @@
41     nh_wom = nh_mday / 7;
42     nh_woy = tm_woy(now);                     /* get week of year */
43  
44 +   Dmsg7(dbglvl, "nh = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
45 +        next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
46 +
47     /* Loop through all jobs */
48     LockRes();
49     foreach_res(job, R_JOB) {
50 @@ -351,24 +357,20 @@
51  
52           Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
53  
54 -         /* find time (time_t) job is to be run */
55 -         (void)localtime_r(&now, &tm);      /* reset tm structure */
56 -         tm.tm_min = run->minute;     /* set run minute */
57 -         tm.tm_sec = 0;               /* zero secs */
58 -         if (run_now) {
59 -            runtime = mktime(&tm);
60 -            add_job(job, run, now, runtime);
61 -         }
62 -         /* If job is to be run in the next hour schedule it */
63 -         if (run_nh) {
64 -            /* Set correct values */
65 -            tm.tm_hour = nh_hour;
66 -            tm.tm_mday = nh_mday + 1; /* fixup because we biased for tests above */
67 -            tm.tm_mon = nh_month;
68 -            tm.tm_year = nh_year;
69 -            runtime = mktime(&tm);
70 -            add_job(job, run, now, runtime);
71 -         }
72 +        if (run_now || run_nh) {
73 +          /* find time (time_t) job is to be run */
74 +          (void)localtime_r(&now, &tm);      /* reset tm structure */
75 +          tm.tm_min = run->minute;     /* set run minute */
76 +          tm.tm_sec = 0;               /* zero secs */
77 +          runtime = mktime(&tm);
78 +          if (run_now) {
79 +            add_job(job, run, now, runtime);
80 +          }
81 +          /* If job is to be run in the next hour schedule it */
82 +          if (run_nh) {
83 +            add_job(job, run, now, runtime + 3600);
84 +          }
85 +        }
86        }
87     }
88     UnlockRes();