From: Kern Sibbald Date: Tue, 6 Jan 2004 20:04:48 +0000 (+0000) Subject: Fix week of month scheduler calculation X-Git-Tag: Release-1.34.0~173 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f25cecedad1a6ba2a31cab34b6e5da1487f6c6a1;p=bacula%2Fbacula Fix week of month scheduler calculation git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@995 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 3429d2ff02..740f3b2757 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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)); } } diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index 977d6199b0..1d2821c63e 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -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 */ diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index f7c6edd440..9725a6e47d 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -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 */ } } diff --git a/bacula/src/lib/btime.c b/bacula/src/lib/btime.c index 825573e2cf..4972a9c9a4 100644 --- a/bacula/src/lib/btime.c +++ b/bacula/src/lib/btime.c @@ -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; }