jcr->term_wait_inited = true;
create_unique_job_name(jcr, jcr->job->name());
- set_jcr_job_status(jcr, JS_Created);
+ jcr->setJobStatus(JS_Created);
jcr->unlock();
/*
Dsm_check(1);
Dmsg0(200, "=====Start Job=========\n");
- set_jcr_job_status(jcr, JS_Running); /* this will be set only if no error */
+ jcr->setJobStatus(JS_Running); /* this will be set only if no error */
jcr->start_time = time(NULL); /* set the real start time */
jcr->jr.StartTime = jcr->start_time;
if (jcr->job->MaxStartDelay != 0 && jcr->job->MaxStartDelay <
(utime_t)(jcr->start_time - jcr->sched_time)) {
- set_jcr_job_status(jcr, JS_Canceled);
+ jcr->setJobStatus(JS_Canceled);
Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n"));
}
if (job_check_maxschedruntime(jcr)) {
- set_jcr_job_status(jcr, JS_Canceled);
+ jcr->setJobStatus(JS_Canceled);
Jmsg(jcr, M_FATAL, 0, _("Job canceled because max sched run time exceeded.\n"));
}
ua->info_msg(_("JobId %s, Job %s marked to be canceled.\n"),
edit_uint64(jcr->JobId, ed1), jcr->Job);
jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
- return true;
+ break;
default:
/* Cancel File daemon */
sd->close();
ua->jcr->store_bsock = NULL;
}
+ break;
}
return true;
void cancel_storage_daemon_job(JCR *jcr)
{
+ if (jcr->sd_canceled) {
+ return; /* cancel only once */
+ }
+
UAContext *ua = new_ua_context(jcr);
JCR *control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM);
BSOCK *sd;
sd->signal(BNET_TERMINATE);
sd->close();
ua->jcr->store_bsock = NULL;
+ jcr->sd_canceled = true;
}
bail_out:
free_jcr(control_jcr);
jcr->jr.VolSessionId = jcr->VolSessionId;
jcr->jr.VolSessionTime = jcr->VolSessionTime;
jcr->jr.JobErrors = jcr->JobErrors;
+ jcr->jr.HasBase = jcr->HasBase;
if (!db_update_job_end_record(jcr, jcr->db, &jcr->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"),
db_strerror(jcr->db));
/*
* Given: a JobId in jcr->previous_jr.JobId,
* this subroutine writes a bsr file to restore that job.
+ * Returns: -1 on error
+ * number of files if OK
*/
-bool create_restore_bootstrap_file(JCR *jcr)
+int create_restore_bootstrap_file(JCR *jcr)
{
RESTORE_CTX rx;
UAContext *ua;
+ int files;
+
memset(&rx, 0, sizeof(rx));
rx.bsr = new_bsr();
rx.JobIds = (char *)"";
rx.bsr->JobId = jcr->previous_jr.JobId;
ua = new_ua_context(jcr);
if (!complete_bsr(ua, rx.bsr)) {
+ files = -1;
goto bail_out;
}
rx.bsr->fi = new_findex();
rx.bsr->fi->findex2 = jcr->previous_jr.JobFiles;
jcr->ExpectedFiles = write_bsr_file(ua, rx);
if (jcr->ExpectedFiles == 0) {
+ files = 0;
goto bail_out;
}
free_ua_context(ua);
free_bsr(rx.bsr);
jcr->needs_sd = true;
- return true;
+ return jcr->ExpectedFiles;
bail_out:
free_ua_context(ua);
free_bsr(rx.bsr);
- return false;
+ return files;
}
/* TODO: redirect command ouput to job log */