]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2610 About incorrect stopping of running job
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Tue, 4 May 2021 20:38:55 +0000 (22:38 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:01 +0000 (09:03 +0100)
Extended 'is_job_canceled()' helper to check for the Incomplete state.
This way, handling job which was either stopped or cancelled is more
elegant (e.g. it is now possible to stop job which was waiting on
mounting volume during backup - it was not possilbe before).

bacula/src/jcr.h
bacula/src/stored/askdir.c

index 09974678906940fa0db27c2034a9388ed735865d..3a8589787b5c0ede53fc0f0f1764d91d9fd2a4e8 100644 (file)
@@ -107,6 +107,7 @@ enum {
 
 #define job_canceled(jcr) \
   (jcr->JobStatus == JS_Canceled || \
+   jcr->JobStatus == JS_Incomplete || \
    jcr->JobStatus == JS_ErrorTerminated || \
    jcr->JobStatus == JS_FatalError \
   )
index e1a2dc2f41ec783f566e0e5305f54d9ed0d6cec0..165dbfbf14c0bbf9e219f259425427f2f84ee28e 100644 (file)
@@ -867,6 +867,15 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
          continue;
       }
 
+      if (stat == W_WAKE) {
+         /* Job could be marked to stopped, need to break */
+         Mmsg0(dev->errmsg, _("Job was stopped by the user.\n"));
+         Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
+         Dmsg1(dbglvl, "Job marked to be stopped. Gave up waiting on device %s\n", dev->print_name());
+         dev->poll = false;
+         return false;
+      }
+
       if (stat == W_TIMEOUT) {
          if (!double_dev_wait_time(dev)) {
             Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device %s for Job %s\n"),