]> git.sur5r.net Git - bacula/bacula/commitdiff
Correct RunScript to terminate job in FD on failure.
authorKern Sibbald <kern@sibbald.com>
Sun, 22 Jul 2007 12:21:06 +0000 (12:21 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 22 Jul 2007 12:21:06 +0000 (12:21 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5222 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/filed/job.c
bacula/src/lib/jcr.c
bacula/src/lib/runscript.c
bacula/technotes-2.1

index 090a10ea83a2adcd1cc2a1ce9e5e78a1cf3eb94f..b8419ba7281a06d03517e015091652800c496bb6 100644 (file)
@@ -492,9 +492,13 @@ static int runbeforenow_cmd(JCR *jcr)
 
    run_scripts(jcr, jcr->RunScripts, "ClientBeforeJob");
    if (job_canceled(jcr)) {
-      return  bnet_fsend(dir, _("2905 Bad RunBeforeNow command.\n"));
+      bnet_fsend(dir, _("2905 Bad RunBeforeNow command.\n"));
+      Dmsg0(100, "Back from run_scripts ClientBeforeJob now: FAILED\n");
+      return 0;
    } else {
-      return  bnet_fsend(dir, OKRunBeforeNow);
+      bnet_fsend(dir, OKRunBeforeNow);
+      Dmsg0(100, "Back from run_scripts ClientBeforeJob now: OK\n");
+      return 1;
    }
 }
 
index a93e53346fda509ee2115b016f51ba46e85b9814..0b5e01fdc84f372f581c3b1b53c1b9a58b9b0f12 100644 (file)
@@ -599,16 +599,28 @@ void set_jcr_job_status(JCR *jcr, int JobStatus)
     * For a set of errors, ... keep the current status
     *   so it isn't lost. For all others, set it.
     */
+   Dmsg2(100, "OnEntry JobStatus=%c set=%c\n", jcr->JobStatus, JobStatus);
    switch (jcr->JobStatus) {
    case JS_ErrorTerminated:
-   case JS_Error:
    case JS_FatalError:
-   case JS_Differences:
    case JS_Canceled:
       break;
+   case JS_Error:
+   case JS_Differences:
+      switch (JobStatus) {
+      case JS_ErrorTerminated:
+      case JS_FatalError:
+      case JS_Canceled:
+         /* Override more minor status */
+         jcr->JobStatus = JobStatus;
+         break;
+      default:
+         break;
+      }
    default:
       jcr->JobStatus = JobStatus;
    }
+   Dmsg2(100, "OnExit JobStatus=%c set=%c\n", jcr->JobStatus, JobStatus);
 }
 
 #ifdef TRACE_JCR_CHAIN
index 7d031aeb70897337a7d52b18adab4827e16d03e6..c36115c3590e84f7106e12dc13c42808370f2a21 100644 (file)
@@ -233,14 +233,16 @@ bool RUNSCRIPT::run(JCR *jcr, const char *name)
          be.code(status), be.bstrerror(status));
       goto bail_out;
    }
+   Dmsg0(100, "runscript OK\n");
    return true;
 
 bail_out:
-     /* cancel running job properly */
-     if (fail_on_error) {
-        set_jcr_job_status(jcr, JS_ErrorTerminated);
-     }
-     return false;
+   /* cancel running job properly */
+   if (fail_on_error) {
+      set_jcr_job_status(jcr, JS_ErrorTerminated);
+   }
+   Dmsg1(100, "runscript failed. fail_on_error=%d\n", fail_on_error);
+   return false;
 }
 
 void free_runscripts(alist *runscripts)
index f2405ff22b885772963098ba1c582d0faa164592..62454e357d9c7d709ae9bfbcaf2d7bbd9a682c9f 100644 (file)
@@ -2,6 +2,7 @@
 
 General:
 22Jul07
+kes  Correct RunScript to terminate job in FD on failure.
 kes  Change abort_on_error and AbortJobOnError to fail_on_error
      and FailJobOnError in RunScripts.
 kes  Minor tweaks of code formating in RunScripts, principally to