return jcr;
}
-/*
- * Priority runs from 0 (lowest) to 10 (highest)
- */
-static int get_status_priority(int JobStatus)
-{
- int priority = 0;
- switch (JobStatus) {
- case JS_ErrorTerminated:
- case JS_FatalError:
- case JS_Canceled:
- case JS_Incomplete:
- priority = 10;
- break;
- case JS_Error:
- priority = 8;
- break;
- case JS_Differences:
- priority = 7;
- break;
- }
- return priority;
-}
-
-
static void update_wait_time(JCR *jcr, int newJobStatus)
{
bool enter_in_waittime;
}
}
+/*
+ * Priority runs from 0 (lowest) to 10 (highest)
+ */
+static int get_status_priority(int JobStatus)
+{
+ int priority = 0;
+ switch (JobStatus) {
+ case JS_ErrorTerminated:
+ case JS_FatalError:
+ case JS_Canceled:
+ case JS_Incomplete:
+ priority = 10;
+ break;
+ case JS_Error:
+ priority = 8;
+ break;
+ case JS_Differences:
+ priority = 7;
+ break;
+ }
+ return priority;
+}
+
+
void set_jcr_job_status(JCR *jcr, int JobStatus)
{
jcr->setJobStatus(JobStatus);
}
-void JCR::setJobStatus(int JobStatus)
+void JCR::setJobStatus(int newJobStatus)
{
JCR *jcr = this;
int priority, old_priority;
- int oldJobStatus = JobStatus;
- priority = get_status_priority(JobStatus);
+ int oldJobStatus = jcr->JobStatus;
+ priority = get_status_priority(newJobStatus);
old_priority = get_status_priority(oldJobStatus);
- Dmsg2(800, "set_jcr_job_status(%s, %c)\n", Job, JobStatus);
+ Dmsg2(800, "set_jcr_job_status(%s, %c)\n", Job, newJobStatus);
/* Update wait_time depending on newJobStatus and oldJobStatus */
- update_wait_time(this, JobStatus);
+ update_wait_time(jcr, newJobStatus);
/*
* For a set of errors, ... keep the current status
* so it isn't lost. For all others, set it.
*/
- Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)JobId,
- JobStatus, JobStatus);
- if (priority >= old_priority) {
- jcr->JobStatus = JobStatus; /* replace with new priority */
+ Dmsg2(800, "OnEntry JobStatus=%c newJobstatus=%c\n", oldJobStatus, newJobStatus);
+ /*
+ * If status priority is > than proposed new status, change it.
+ * If status priority == new priority and both are zero, take
+ * the new status.
+ * If it is not zero, then we keep the first non-zero "error" that
+ * occurred.
+ */
+ if (priority > old_priority || (
+ priority == 0 && old_priority == 0)) {
+ Dmsg4(800, "Set new stat. old: %c,%d new: %c,%d\n",
+ jcr->JobStatus, old_priority, newJobStatus, priority);
+ jcr->JobStatus = newJobStatus; /* replace with new status */
}
if (oldJobStatus != jcr->JobStatus) {
- Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
- oldJobStatus, JobStatus);
+ Dmsg2(800, "leave set_job_status old=%c new=%c\n", oldJobStatus, newJobStatus);
// generate_plugin_event(jcr, bEventStatusChange, NULL);
}
}