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:
7 patch -p0 <2.0.3-scheduler-next-hour.patch
12 Index: src/dird/scheduler.c
13 ===================================================================
14 --- src/dird/scheduler.c (revision 4445)
15 +++ src/dird/scheduler.c (working copy)
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.
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;
32 woy = tm_woy(now); /* get week of year */
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);
38 * Compute values for next hour from now.
39 * We do this to be sure we don't miss a job while
42 nh_woy = tm_woy(now); /* get week of year */
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);
47 /* Loop through all jobs */
49 foreach_res(job, R_JOB) {
52 Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
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 */
59 - runtime = mktime(&tm);
60 - add_job(job, run, now, runtime);
62 - /* If job is to be run in the next hour schedule it */
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);
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);
79 + add_job(job, run, now, runtime);
81 + /* If job is to be run in the next hour schedule it */
83 + add_job(job, run, now, runtime + 3600);