From: Eric Bollengier Date: Tue, 25 Sep 2012 10:16:17 +0000 (+0200) Subject: Fix #4996 about MaxRunTime canceling the job too early X-Git-Tag: Release-7.0.0~91 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7b1feff61868e2b2bde780dcfc0816509b449100;p=bacula%2Fbacula Fix #4996 about MaxRunTime canceling the job too early --- diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 77a3845e2d..65d5803d3b 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -418,6 +418,10 @@ bool do_backup(JCR *jcr) goto bail_out; } + /* Declare the job started to start the MaxRunTime check */ + jcr->setJobStarted(); + + /* Send and run the RunBefore */ if (!send_runscripts_commands(jcr)) { goto bail_out; } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index dae019bc7c..9865e373db 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -611,7 +611,7 @@ static bool job_check_maxruntime(JCR *jcr) JOB *job = jcr->job; utime_t run_time; - if (job_canceled(jcr) || jcr->JobStatus == JS_Created) { + if (job_canceled(jcr) || !jcr->job_started) { return false; } if (jcr->job->MaxRunTime == 0 && job->FullMaxRunTime == 0 && diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 5193921145..c4738eada9 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -365,6 +365,8 @@ bool do_migration(JCR *jcr) } Dmsg0(150, "Storage daemon connection OK\n"); + /* Declare the job started to start the MaxRunTime check */ + jcr->setJobStarted(); /* * We re-update the job start record so that the start diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 0a8945afd9..eee86be879 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -432,6 +432,9 @@ bool restore_bootstrap(JCR *jcr) goto bail_out; } + /* Declare the job started to start the MaxRunTime check */ + jcr->setJobStarted(); + /* Only pass "global" commands to the FD once */ if (first_time) { first_time = false; diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index f24f9d61b2..2babd36d0d 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -232,6 +232,9 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n") return false; } + /* Declare the job started to start the MaxRunTime check */ + jcr->setJobStarted(); + /* * Start the job prior to starting the message thread below * to avoid two threads from using the BSOCK structure at diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index a017d1b04d..0ff93ab0c3 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -118,6 +118,7 @@ enum { ) #define job_waiting(jcr) \ + (jcr->job_started && \ (jcr->JobStatus == JS_WaitFD || \ jcr->JobStatus == JS_WaitSD || \ jcr->JobStatus == JS_WaitMedia || \ @@ -130,7 +131,7 @@ enum { jcr->SDJobStatus == JS_WaitMedia || \ jcr->SDJobStatus == JS_WaitMount || \ jcr->SDJobStatus == JS_WaitDevice || \ - jcr->SDJobStatus == JS_WaitMaxJobs) + jcr->SDJobStatus == JS_WaitMaxJobs)) @@ -199,6 +200,7 @@ public: void setJobLevel(int32_t JobLevel) { m_JobLevel = JobLevel; }; void setJobType(int32_t JobType) { m_JobType = JobType; }; void forceJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; }; + void setJobStarted(); int32_t getJobType() const { return m_JobType; }; int32_t getJobLevel() const { return m_JobLevel; }; int32_t getJobStatus() const { return JobStatus; }; @@ -253,6 +255,7 @@ public: time_t end_time; /* job end time */ time_t wait_time_sum; /* cumulative wait time since job start */ time_t wait_time; /* timestamp when job have started to wait */ + time_t job_started_time; /* Time when the MaxRunTime start to count */ POOLMEM *client_name; /* client name */ POOLMEM *JobIds; /* User entered string of JobIds */ POOLMEM *RestoreBootstrap; /* Bootstrap file to restore */ @@ -276,6 +279,7 @@ public: bool accurate; /* true if job is accurate */ bool HasBase; /* True if job use base jobs */ bool rerunning; /* rerunning an incomplete job */ + bool job_started; /* Set when the job is actually started */ void *Python_job; /* Python Job Object */ void *Python_events; /* Python Events Object */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index d895ba13cc..53679c4c83 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -892,6 +892,12 @@ bool JCR::sendJobStatus(int newJobStatus) return true; } +void JCR::setJobStarted() +{ + JCR *jcr = this; + jcr->job_started = true; + jcr->job_started_time = time(NULL); +} void JCR::setJobStatus(int newJobStatus) {