]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/job.c
Fix bug #1268 Full Max Run Time cancels jobs (when Max Run Time = 0).
[bacula/bacula] / bacula / src / dird / job.c
index d70e589226f920e607ffb869910b9cd01b979180..252a89a8651692c35c91dddb0490e0dd2ec4e0a7 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 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.
@@ -578,6 +578,7 @@ static bool job_check_maxruntime(JCR *jcr)
 {
    bool cancel = false;
    JOB *job = jcr->job;
+   utime_t run_time;
 
    if (job_canceled(jcr) || jcr->JobStatus == JS_Created) {
       return false;
@@ -586,20 +587,25 @@ static bool job_check_maxruntime(JCR *jcr)
        job->IncMaxRunTime == 0 && job->DiffMaxRunTime == 0) {
       return false;
    }
-   Dmsg6(200, "check_maxruntime %u - %u >= %u|%u|%u|%u\n\n",
-         watchdog_time, jcr->start_time, job->MaxRunTime, job->FullMaxRunTime, 
+   run_time = watchdog_time - jcr->start_time;
+   Dmsg7(200, "check_maxruntime %llu-%u=%llu >= %llu|%llu|%llu|%llu\n",
+         watchdog_time, jcr->start_time, run_time, job->MaxRunTime, job->FullMaxRunTime, 
          job->IncMaxRunTime, job->DiffMaxRunTime);
 
    if (jcr->get_JobLevel() == L_FULL && job->FullMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->FullMaxRunTime) {
+         run_time >= job->FullMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: FullMaxcancel\n");
       cancel = true;
    } else if (jcr->get_JobLevel() == L_DIFFERENTIAL && job->DiffMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->DiffMaxRunTime) {
+         run_time >= job->DiffMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: DiffMaxcancel\n");
       cancel = true;
    } else if (jcr->get_JobLevel() == L_INCREMENTAL && job->IncMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->IncMaxRunTime) {
+         run_time >= job->IncMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: IncMaxcancel\n");
       cancel = true;
-   } else if ((watchdog_time - jcr->start_time) >= job->MaxRunTime) {
+   } else if (job->MaxRunTime > 0 && run_time >= job->MaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: Maxcancel\n");
       cancel = true;
    }
  
@@ -863,7 +869,7 @@ void update_job_end_record(JCR *jcr)
    jcr->jr.ReadBytes = jcr->ReadBytes;
    jcr->jr.VolSessionId = jcr->VolSessionId;
    jcr->jr.VolSessionTime = jcr->VolSessionTime;
-   jcr->jr.JobErrors = jcr->Errors;
+   jcr->jr.JobErrors = jcr->JobErrors;
    if (!db_update_job_end_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"),
          db_strerror(jcr->db));
@@ -916,7 +922,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    len = strlen(dt) + 5;   /* dt + .%02d EOS */
    bstrncpy(name, base_name, sizeof(name));
    name[sizeof(name)-len] = 0;          /* truncate if too long */
-   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s.%02d", name, dt, seq); /* add date & time */
+   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s_%02d", name, dt, seq); /* add date & time */
    /* Convert spaces into underscores */
    for (p=jcr->Job; *p; p++) {
       if (*p == ' ') {
@@ -1342,7 +1348,8 @@ void create_clones(JCR *jcr)
          parse_ua_args(ua);                 /* parse command */
          int stat = run_cmd(ua, ua->cmd);
          if (stat == 0) {
-            Jmsg(jcr, M_ERROR, 0, _("Could not start clone job.\n"));
+            Jmsg(jcr, M_ERROR, 0, _("Could not start clone job: \"%s\".\n"),
+                 ua->cmd);
          } else {
             Jmsg(jcr, M_INFO, 0, _("Clone JobId %d started.\n"), stat);
          }
@@ -1387,7 +1394,8 @@ bail_out:
 }
 
 /* TODO: redirect command ouput to job log */
-bool run_console_command(JCR *jcr, const char *cmd){
+bool run_console_command(JCR *jcr, const char *cmd)
+{
    UAContext *ua;
    bool ok;
    JCR *ljcr = new_control_jcr("-RunScript-", JT_CONSOLE);