0745245
0745245
 This patch should fix bug #812 where the DST time shift was 
0745245
 incorrectly handled. This patch was submitted by Martin Simmons.
0745245
 Apply it to Bacula version 2.0.3 with:
0745245
0745245
  cd <bacula-source>
0745245
  patch -p0 <2.0.3-scheduler-next-hour.patch
0745245
  make
0745245
  ...
0745245
  make install
0745245
0745245
Index: src/dird/scheduler.c
0745245
===================================================================
0745245
--- src/dird/scheduler.c	(revision 4445)
0745245
+++ src/dird/scheduler.c	(working copy)
0745245
@@ -175,11 +175,11 @@
0745245
       }
0745245
       /* Recheck at least once per minute */
0745245
       bmicrosleep((next_check_secs < twait)?next_check_secs:twait, 0);
0745245
-      /* Attempt to handle clock shift from/to daylight savings time
0745245
+      /* Attempt to handle clock shift (but not daylight savings time changes)
0745245
        * we allow a skew of 10 seconds before invalidating everything.
0745245
        */
0745245
       now = time(NULL);
0745245
-      if (now < prev+10 || now > (prev+next_check_secs+10)) {
0745245
+      if (now < prev-10 || now > (prev+next_check_secs+10)) {
0745245
          schedules_invalidated = true;
0745245
       }
0745245
    }
0745245
@@ -284,6 +284,9 @@
0745245
    wom = mday / 7;
0745245
    woy = tm_woy(now);                     /* get week of year */
0745245
 
0745245
+   Dmsg7(dbglvl, "now = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
0745245
+	 now, hour, month, mday, wday, wom, woy);
0745245
+
0745245
    /*
0745245
     * Compute values for next hour from now.
0745245
     * We do this to be sure we don't miss a job while
0745245
@@ -299,6 +302,9 @@
0745245
    nh_wom = nh_mday / 7;
0745245
    nh_woy = tm_woy(now);                     /* get week of year */
0745245
 
0745245
+   Dmsg7(dbglvl, "nh = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
0745245
+	 next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
0745245
+
0745245
    /* Loop through all jobs */
0745245
    LockRes();
0745245
    foreach_res(job, R_JOB) {
0745245
@@ -351,24 +357,20 @@
0745245
 
0745245
          Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
0745245
 
0745245
-         /* find time (time_t) job is to be run */
0745245
-         (void)localtime_r(&now, &tm;;      /* reset tm structure */
0745245
-         tm.tm_min = run->minute;     /* set run minute */
0745245
-         tm.tm_sec = 0;               /* zero secs */
0745245
-         if (run_now) {
0745245
-            runtime = mktime(&tm;;
0745245
-            add_job(job, run, now, runtime);
0745245
-         }
0745245
-         /* If job is to be run in the next hour schedule it */
0745245
-         if (run_nh) {
0745245
-            /* Set correct values */
0745245
-            tm.tm_hour = nh_hour;
0745245
-            tm.tm_mday = nh_mday + 1; /* fixup because we biased for tests above */
0745245
-            tm.tm_mon = nh_month;
0745245
-            tm.tm_year = nh_year;
0745245
-            runtime = mktime(&tm;;
0745245
-            add_job(job, run, now, runtime);
0745245
-         }
0745245
+	 if (run_now || run_nh) {
0745245
+	   /* find time (time_t) job is to be run */
0745245
+	   (void)localtime_r(&now, &tm;;      /* reset tm structure */
0745245
+	   tm.tm_min = run->minute;     /* set run minute */
0745245
+	   tm.tm_sec = 0;               /* zero secs */
0745245
+	   runtime = mktime(&tm;;
0745245
+	   if (run_now) {
0745245
+	     add_job(job, run, now, runtime);
0745245
+	   }
0745245
+	   /* If job is to be run in the next hour schedule it */
0745245
+	   if (run_nh) {
0745245
+	     add_job(job, run, now, runtime + 3600);
0745245
+	   }
0745245
+	 }
0745245
       }
0745245
    }
0745245
    UnlockRes();