]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/scheduler.c
Fix bat seg fault
[bacula/bacula] / bacula / src / dird / scheduler.c
index 0e888a7c128708033949faa0443bed4205bc24a0..6bcc3daf80e63f0d56bbd97e2dd3d7f25e566f8e 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
    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
+   You should have received a copy of the GNU Affero 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 John Walker.
+   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.
@@ -118,6 +118,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
          return jcr;
       }
    }
+
    /* Wait until we have something in the
     * next hour or so.
     */
@@ -199,7 +200,7 @@ again:
    ASSERT(job);
    set_jcr_defaults(jcr, job);
    if (run->level) {
-      jcr->JobLevel = run->level;     /* override run level */
+      jcr->set_JobLevel(run->level);  /* override run level */
    }
    if (run->pool) {
       jcr->pool = run->pool;          /* override pool */
@@ -246,11 +247,6 @@ again:
 void term_scheduler()
 {
    if (jobs_to_run) {
-      job_item *je;
-      /* Release all queued job entries to be run */
-      foreach_dlist(je, jobs_to_run) {
-         free(je);
-      }
       delete jobs_to_run;
    }
 }
@@ -285,7 +281,7 @@ static void find_runs()
    woy = tm_woy(now);                     /* get week of year */
 
    Dmsg7(dbglvl, "now = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
-        now, hour, month, mday, wday, wom, woy);
+         now, hour, month, mday, wday, wom, woy);
 
    /*
     * Compute values for next hour from now.
@@ -303,7 +299,7 @@ static void find_runs()
    nh_woy = tm_woy(now);                     /* get week of year */
 
    Dmsg7(dbglvl, "nh = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
-        next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
+         next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
 
    /* Loop through all jobs */
    LockRes();
@@ -357,20 +353,20 @@ static void find_runs()
 
          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);
-          }
-        }
+         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);
+           }
+         }
       }
    }
    UnlockRes();
@@ -387,19 +383,15 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime)
     */
    if (((runtime - run->last_run) < 61) || ((runtime+59) < now)) {
 #ifdef SCHED_DEBUG
-      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);
-      Dmsg7(000, "Drop: Job=\"%s\" run=%s(%x). last_run=%s(%x). now=%s(%x)\n", job->hdr.name, 
-            dt, runtime, dt1, run->last_run, dt2, now);
+      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);
 #endif
       return;
    }
 #ifdef SCHED_DEBUG
-   Dmsg4(000, "Add: Job=\"%s\" run=%x last_run=%x now=%x\n", job->hdr.name, 
-            runtime, run->last_run, now);
+   Dmsg4(000, "Add: Job=\"%s\" run=%lld last_run=%lld now=%lld\n", job->hdr.name, 
+            (utime_t)runtime, (utime_t)run->last_run, (utime_t)now);
 #endif
    /* accept to run this job */
    job_item *je = (job_item *)malloc(sizeof(job_item));