+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of Kern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
-/*
- Copyright (C) 2000-2004 Kern Sibbald and John Walker
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
-
- */
- Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
- hour, month, mday, wday, wom, woy);
- Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
- bit_is_set(hour, run->hour),
- bit_is_set(month, run->month),
- bit_is_set(mday, run->mday),
- bit_is_set(wday, run->wday),
- bit_is_set(wom, run->wom),
- bit_is_set(woy, run->woy));
-
- Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
- nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
- Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
- bit_is_set(nh_hour, run->hour),
- bit_is_set(nh_month, run->month),
- bit_is_set(nh_mday, run->mday),
- bit_is_set(nh_wday, run->wday),
- bit_is_set(nh_wom, run->wom),
- bit_is_set(nh_woy, run->woy));
+ Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
+ hour, month, mday, wday, wom, woy);
+ Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
+ bit_is_set(hour, run->hour),
+ bit_is_set(month, run->month),
+ bit_is_set(mday, run->mday),
+ bit_is_set(wday, run->wday),
+ bit_is_set(wom, run->wom),
+ bit_is_set(woy, run->woy));
+
+ Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
+ nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
+ Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
+ bit_is_set(nh_hour, run->hour),
+ bit_is_set(nh_month, run->month),
+ bit_is_set(nh_mday, run->mday),
+ bit_is_set(nh_wday, run->wday),
+ bit_is_set(nh_wom, run->wom),
+ bit_is_set(nh_woy, run->woy));
- run_now = bit_is_set(hour, run->hour) &&
- (bit_is_set(mday, run->mday) || bit_is_set(wday, run->wday)) &&
- bit_is_set(month, run->month) &&
- bit_is_set(wom, run->wom) &&
- bit_is_set(woy, run->woy);
-
- run_nh = bit_is_set(nh_hour, run->hour) &&
- (bit_is_set(nh_mday, run->mday) || bit_is_set(nh_wday, run->wday)) &&
- bit_is_set(nh_month, run->month) &&
- bit_is_set(nh_wom, run->wom) &&
- bit_is_set(nh_woy, run->woy);
-
- Dmsg2(200, "run_now=%d run_nh=%d\n", run_now, run_nh);
-
- /* find time (time_t) job is to be run */
- localtime_r(&now, &tm); /* reset tm structure */
- tm.tm_min = run->minute; /* set run minute */
- tm.tm_sec = 0; /* zero secs */
- if (run_now) {
- runtime = mktime(&tm);
- add_job(job, run, now, runtime);
- }
- /* If job is to be run in the next hour schedule it */
- if (run_nh) {
- /* Set correct values */
- tm.tm_hour = nh_hour;
- tm.tm_mday = nh_mday + 1; /* fixup because we biased for tests above */
- tm.tm_mon = nh_month;
- tm.tm_year = nh_year;
- runtime = mktime(&tm);
- add_job(job, run, now, runtime);
- }
- }
+ run_now = bit_is_set(hour, run->hour) &&
+ bit_is_set(mday, run->mday) &&
+ bit_is_set(wday, run->wday) &&
+ bit_is_set(month, run->month) &&
+ bit_is_set(wom, run->wom) &&
+ bit_is_set(woy, run->woy);
+
+ run_nh = bit_is_set(nh_hour, run->hour) &&
+ bit_is_set(nh_mday, run->mday) &&
+ bit_is_set(nh_wday, run->wday) &&
+ bit_is_set(nh_month, run->month) &&
+ bit_is_set(nh_wom, run->wom) &&
+ bit_is_set(nh_woy, run->woy);
+
+ Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
+
+ if (run_now || run_nh) {
+ /* find time (time_t) job is to be run */
+ (void)localtime_r(&now, &tm); /* reset tm structure */
+ tm.tm_min = run->minute; /* set run minute */
+ tm.tm_sec = 0; /* zero secs */
+ runtime = mktime(&tm);
+ if (run_now) {
+ add_job(job, run, now, runtime);
+ }
+ /* If job is to be run in the next hour schedule it */
+ if (run_nh) {
+ add_job(job, run, now, runtime + 3600);
+ }
+ }
+ }
-#ifdef PHIL
- char dt[50], dt1[50], dt2[50];
- bstrftime_nc(dt, sizeof(dt), runtime);
- bstrftime_nc(dt1, sizeof(dt1), run->last_run);
- bstrftime_nc(dt2, sizeof(dt2), now);
- Dmsg4(000, "Drop: Job=%s run=%s. last_run=%s. now=%s\n", job->hdr.name,
- dt, dt1, dt2);
+#ifdef SCHED_DEBUG
+ Dmsg4(000, "Drop: Job=\"%s\" run=%lld. last_run=%lld. now=%lld\n", job->hdr.name,
+ (utime_t)runtime, (utime_t)run->last_run, (utime_t)now);
+ fflush(stdout);