]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix week of month scheduler calculation
authorKern Sibbald <kern@sibbald.com>
Tue, 6 Jan 2004 20:04:48 +0000 (20:04 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 6 Jan 2004 20:04:48 +0000 (20:04 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@995 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/dird_conf.c
bacula/src/dird/scheduler.c
bacula/src/dird/ua_output.c
bacula/src/lib/btime.c

index 3429d2ff02d881abb83d38364edaabcd21e04873..740f3b2757cd48024dacfc061e715b00d48fdba0 100644 (file)
@@ -586,7 +586,7 @@ next_run:
          bstrncpy(buf, "      mday=", sizeof(buf));
         for (i=0; i<31; i++) {
            if (bit_is_set(i, run->mday)) {
-               sprintf(num, "%d ", i+1);
+               sprintf(num, "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
@@ -595,7 +595,7 @@ next_run:
          bstrncpy(buf, "      month=", sizeof(buf));
         for (i=0; i<12; i++) {
            if (bit_is_set(i, run->month)) {
-               sprintf(num, "%d ", i+1);
+               sprintf(num, "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
@@ -604,7 +604,7 @@ next_run:
          bstrncpy(buf, "      wday=", sizeof(buf));
         for (i=0; i<7; i++) {
            if (bit_is_set(i, run->wday)) {
-               sprintf(num, "%d ", i+1);
+               sprintf(num, "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
@@ -613,7 +613,7 @@ next_run:
          bstrncpy(buf, "      wom=", sizeof(buf));
         for (i=0; i<5; i++) {
            if (bit_is_set(i, run->wom)) {
-               sprintf(num, "%d ", i+1);
+               sprintf(num, "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
index 977d6199b0d284ad1e6f867541ca6b4e8013304a..1d2821c63e956ae83b16e1c4db5343346280d156 100644 (file)
@@ -201,7 +201,7 @@ static void find_runs()
    mday = tm.tm_mday - 1;
    wday = tm.tm_wday;
    month = tm.tm_mon;
-   wom = tm_wom(tm.tm_mday, tm.tm_wday);  /* get week of month */
+   wom = mday / 7;
    woy = tm_woy(now);                    /* get week of year */
 
    /* 
@@ -216,7 +216,7 @@ static void find_runs()
    nh_wday = tm.tm_wday;
    nh_month = tm.tm_mon;
    nh_year  = tm.tm_year;
-   nh_wom = tm_wom(tm.tm_mday, tm.tm_wday);  /* get week of month */
+   nh_wom = nh_mday / 7;
    nh_woy = tm_woy(now);                    /* get week of year */
 
    /* Loop through all jobs */
index f7c6edd4403a87493945e556ce8d09987e034ec9..9725a6e47d28412e90c2ba0120f28f443051bd7a 100644 (file)
@@ -454,7 +454,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
    mday = tm.tm_mday - 1;
    wday = tm.tm_wday;
    month = tm.tm_mon;
-   wom = tm_wom(tm.tm_mday, tm.tm_wday);
+   wom = mday / 7;
    woy = tm_woy(now);
 
    /* Break down tomorrow into components */
@@ -463,7 +463,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
    tmday = tm.tm_mday - 1;
    twday = tm.tm_wday;
    tmonth = tm.tm_mon;
-   twom  = tm_wom(tm.tm_mday, tm.tm_wday);
+   twom = tmday / 7;
    twoy  = tm_woy(tomorrow);
 
    if (run == NULL) {
@@ -483,7 +483,9 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
             bit_is_set(tmonth, run->month) && bit_is_set(twom, run->wom) &&
             bit_is_set(twoy, run->woy);
 
-      Dmsg2(200, "tod=%d tom=%d\n", tod, tom);
+//    Dmsg2(200, "tod=%d tom=%d\n", tod, tom);
+//    Dmsg2(200, "wom=%d twom=%d\n", wom, twom);
+//    Dmsg1(200, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
       if (tod) {                  /* Jobs scheduled today (next 24 hours) */
         /* find time (time_t) job is to be run */
         localtime_r(&now, &tm);
@@ -495,6 +497,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
               tm.tm_sec = 0;
               runtime = mktime(&tm);
               if (runtime > now) {
+                  Dmsg2(000, "Found it level=%d %c\n", run->level, run->level);
                  return run;         /* found it, return run resource */
               }
            }
index 825573e2cf37fd853282ad35d90fd61b4927626f..4972a9c9a446c946e74a9af438304c5300259016 100644 (file)
@@ -136,7 +136,7 @@ utime_t btime_to_utime(btime_t bt)
 }
 
 /*
- * Return the week of the month, base 0 (wpos)
+ * Return the week of the month, base 0 (wom)
  *   given tm_mday and tm_wday. Value returned
  *   can be from 0 to 4 => week1, ... week5
  */
@@ -148,11 +148,11 @@ int tm_wom(int mday, int wday)
       fs += 7;
    }
    if (mday <= fs) {
-//    Dmsg2(100, "wom=0 wday=%d <= fs=%d\n", wday, fs);
+//    Dmsg3(100, "mday=%d wom=0 wday=%d <= fs=%d\n", mday, wday, fs);
       return 0;
    }
    int wom = 1 + (mday - fs - 1) / 7;
-// Dmsg3(100, "wom=%d wday=%d fs=%d\n", wom, wday, fs);
+// Dmsg4(100, "mday=%d wom=%d wday=%d fs=%d\n", mday, wom, wday, fs);
    return wom;
 }