char ed1[50];
int32_t old_status = jcr->JobStatus;
int status;
+ bool ret = false;
const char *reason, *cmd;
/* Keep track of this important event */
case JS_WaitMaxJobs:
case JS_WaitStartTime:
case JS_WaitDevice:
- ua->info_msg(_("JobId %s, Job %s marked to be %s.\n"),
- edit_uint64(jcr->JobId, ed1), jcr->Job,
- reason);
- jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
+ status = jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
+ if (status != 0) {
+ ua->error_msg(_("Cannot %s JobId %s, Job %s is not in work queue\n"),
+ cmd, edit_uint64(jcr->JobId, ed1), jcr->Job);
+ goto bail_out;
+ }
break;
default:
+ ret = true; /* This will be set to false in case of error from any daemon below */
/* Cancel File daemon */
if (jcr->file_bsock) {
btimer_t *tid;
/* do not return now, we want to try to cancel the sd */
tid = start_bsock_timer(jcr->file_bsock, 120);
- cancel_file_daemon_job(ua, cmd, jcr);
+ if (!cancel_file_daemon_job(ua, cmd, jcr)) {
+ Dmsg1(400, "Failed to cancel file dameon job id=%d\n", jcr->JobId);
+ ret = false;
+ }
stop_bsock_timer(tid);
}
btimer_t *tid;
/* do not return now, we want to try to cancel the sd socket */
tid = start_bsock_timer(jcr->store_bsock, 120);
- cancel_sd_job(ua, cmd, jcr);
+ if (!cancel_sd_job(ua, cmd, jcr)) {
+ Dmsg1(400, "Failed to cancel storage dameon job id=%d\n", jcr->JobId);
+ ret = false;
+ }
stop_bsock_timer(tid);
}
btimer_t *tid;
/* do not return now, we want to try to cancel the sd socket */
tid = start_bsock_timer(wjcr->store_bsock, 120);
- cancel_sd_job(ua, cmd, wjcr);
+ if (!cancel_sd_job(ua, cmd, wjcr)) {
+ Dmsg1(400, "Failed to cancel storage dameon job id=%d\n", jcr->JobId);
+ ret = false;
+ }
stop_bsock_timer(tid);
}
/* We test store_bsock because the previous operation can take
wjcr->my_thread_send_signal(TIMEOUT_SIGNAL);
}
}
+
+ if (!ret) {
+ goto bail_out;
+ }
+
break;
}
- return true;
+ ua->info_msg(_("JobId %s, Job %s marked to be %s.\n"),
+ edit_uint64(jcr->JobId, ed1), jcr->Job,
+ reason);
+
+bail_out:
+ return ret;
}
void cancel_storage_daemon_job(JCR *jcr)
foreach_alist(jcr, jcrs) {
/* Execute the cancel command only if we don't have an error */
if (nb != -1) {
+ /* If runtime is not set it means that job is waiting on something (e.g. some resource to appear).
+ * It then makes more sense to cancel job rather than stop it since it hasn't been started at all. */
+ if (!jcr->run_time && !cancel) {
+ ua->info_msg(_("1000 Trying to cancel Job %s since it was not started yet hence "
+ "no need for stopping it.\n"), jcr->Job);
+ }
+ cancel = jcr->run_time ? cancel : true;
+
ret &= cancel_job(ua, jcr, 60, cancel);
}
free_jcr(jcr);
for (bool running=true; running; ) {
running = false;
foreach_jcr(jcr) {
+
if (!jcr->is_internal_job()) {
running = true;
break;
continue;
}
+ if (stat == W_WAKE) {
+ /* Job could be marked to stopped, need to brea */
+ 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"),