From: Eric Bollengier Date: Mon, 28 Aug 2017 12:47:48 +0000 (+0200) Subject: Fix #2925 Do not try to stop non backup jobs (virtualfull, copy, migration, restore... X-Git-Tag: Release-9.0.4~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=abd8c1fdc7d84319524dc6fcf4bcd7cf7a5bdbaf;p=bacula%2Fbacula Fix #2925 Do not try to stop non backup jobs (virtualfull, copy, migration, restore, etc...) The code to handle restart incomplete restore/copy/migration jobs is not implemented. --- diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 1939aecefc..b5b39c7d5a 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -680,8 +680,14 @@ cancel_job(UAContext *ua, JCR *jcr, int wait, bool cancel) int status; const char *reason, *cmd; - Dmsg3(10, "cancel_job jcr=%p jobid=%d use_count\n", jcr, jcr->JobId, jcr->use_count()); - + if (!cancel) { /* stop the job */ + if (!jcr->can_be_stopped()) { + ua->error_msg(_("Cannot stop JobId %s, Job %s is not a regular Backup Job\n"), + edit_uint64(jcr->JobId, ed1), jcr->Job); + return true; + } + } + if (cancel) { status = JS_Canceled; reason = _("canceled"); diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index a4d2fb070a..dae83c06e8 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -214,6 +214,7 @@ public: bool no_client_used() const { return (m_JobLevel == L_VIRTUAL_FULL); }; + bool can_be_stopped(); /* in lib/jcr.c */ const char *get_OperationName(); /* in lib/jcr.c */ const char *get_ActionName(bool past); /* in lib/jcr.c */ void setJobStatus(int JobStatus); /* in lib/jcr.c */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 3f76cf5e81..8aafd522d6 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -280,6 +280,23 @@ bool JCR::JobReads() return false; } +/* We can stop only Backup jobs connected to a client. It doesn't make sens at + * this time to stop a copy, migraton, restore or a verify job. The specific + * code should be implemented first. + */ +bool JCR::can_be_stopped() +{ + bool ok=true; + if (getJobType() == JT_BACKUP) { /* Is a Backup */ + if (getJobLevel() == L_VIRTUAL_FULL) { /* Is a VirtualFull */ + ok = false; + } + } else { /* Is not a backup (so, copy, migration, admin, verify, ... */ + ok = false; + } + return ok; +} + /* * Push a subroutine address into the job end callback stack */