*
*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include "bacula.h"
#include "jcr.h"
+extern void timeout_handler(int sig);
+
struct s_last_job last_job; /* last job run by this daemon */
static JCR *jobs = NULL; /* pointer to JCR chain */
JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
{
JCR *jcr;
+ struct sigaction sigtimer;
Dmsg0(200, "Enter new_jcr\n");
- jcr = (JCR *) malloc(size);
+ jcr = (JCR *)malloc(size);
memset(jcr, 0, size);
jcr->my_thread_id = pthread_self();
jcr->sched_time = time(NULL);
jcr->errmsg = get_pool_memory(PM_MESSAGE);
jcr->errmsg[0] = 0;
+ sigtimer.sa_flags = 0;
+ sigtimer.sa_handler = timeout_handler;
+ sigfillset(&sigtimer.sa_mask);
+ sigaction(TIMEOUT_SIGNAL, &sigtimer, NULL);
+
P(mutex);
jcr->prev = NULL;
jcr->next = jobs;
remove_jcr(jcr);
V(mutex);
- jcr->daemon_free_jcr(jcr); /* call daemon free routine */
+ if (jcr->daemon_free_jcr) {
+ jcr->daemon_free_jcr(jcr); /* call daemon free routine */
+ }
free_common_jcr(jcr);
+
+ P(mutex);
+ close_msg(NULL); /* flush any daemon messages */
+ V(mutex);
Dmsg0(200, "Exit free_jcr\n");
}
return jcr;
}
+void set_jcr_job_status(JCR *jcr, int JobStatus)
+{
+ /*
+ * For a set of errors, ... keep the current status
+ * so it isn't lost. For all others, set it.
+ */
+ switch (jcr->JobStatus) {
+ case JS_ErrorTerminated:
+ case JS_Error:
+ case JS_FatalError:
+ case JS_Differences:
+ case JS_Canceled:
+ break;
+ default:
+ jcr->JobStatus = JobStatus;
+ }
+}
+
/*
* Lock the chain
*/