1 Index: src/dird/backup.c
2 ===================================================================
3 --- src/dird/backup.c (revision 7725)
4 +++ src/dird/backup.c (working copy)
6 Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"),
7 edit_uint64(jcr->JobId, ed1), jcr->Job);
9 + jcr->set_owner(); /* we are responsible for this job */
10 set_jcr_job_status(jcr, JS_Running);
11 Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel);
12 if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
15 tid = start_bsock_timer(fd, timeout); /* TODO: New timeout directive??? */
17 + Dmsg0(1, "======== Wait for a message\n");
18 /* Wait for Client to terminate */
19 while ((n = bget_dirmsg(fd)) >= 0) {
20 + Dmsg1(1, "======= Get client message=%s\n", fd->msg);
22 (sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles,
23 &ReadBytes, &JobBytes, &Errors, &VSS, &Encrypt) == 7 ||
25 ===================================================================
26 --- src/dird/job.c (revision 7731)
27 +++ src/dird/job.c (working copy)
29 jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
33 + if (jcr->get_JobType() == JT_BACKUP && jcr->file_bsock) {
34 + /* When in JS_Running state, the main thread can wait for
35 + * EndJob message from the Client. We send a signal to the job
36 + * thread to cancel the read()
38 + jcr->send_signal_to_owner(TIMEOUT_SIGNAL);
41 /* Cancel File daemon */
42 if (jcr->file_bsock) {
44 ===================================================================
45 --- src/jcr.h (revision 7725)
46 +++ src/jcr.h (working copy)
48 bool is_job_canceled() {return job_canceled(this); };
49 int32_t get_JobType() { return m_JobType; };
50 int32_t get_JobLevel() { return m_JobLevel; };
52 + int send_signal_to_owner(int signal);
54 const char *get_OperationName(); /* in lib/jcr.c */
55 const char *get_ActionName(bool past); /* in lib/jcr.c */
57 ===================================================================
58 --- src/lib/jcr.c (revision 7725)
59 +++ src/lib/jcr.c (working copy)
64 + * Update the my_thread_id variable with the current thread id
66 +void JCR::set_owner()
68 + Dmsg1(0, "JCR::set_owner(%p)\n", pthread_self());
69 + this->my_thread_id = pthread_self();
73 + * Send a signal to the JCR thread owner. (to break a system call)
74 + * (Must have use set_owner() before)
76 +int JCR::send_signal_to_owner(int sig)
79 + Dmsg2(0, "Sending TIMEOUT ?? to %p by %p\n", this->my_thread_id, pthread_self());
81 + if (!pthread_equal(this->my_thread_id, pthread_self())) {
82 + Dmsg2(0, "Sending TIMEOUT to %p by %p\n", this->my_thread_id, pthread_self());
83 + ret = pthread_kill(this->my_thread_id, sig);
89 * Push a subroutine address into the job end callback stack
91 void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx)
93 bool set_waittime = false;
94 int oldJobStatus = jcr->JobStatus;
96 - Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
97 + Dmsg2(2, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
98 /* if wait state is new, we keep current time for watchdog MaxWaitTime */
102 * For a set of errors, ... keep the current status
103 * so it isn't lost. For all others, set it.
105 - Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
106 + Dmsg3(2, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
107 jcr->JobStatus, JobStatus);
108 switch (jcr->JobStatus) {
109 case JS_ErrorTerminated:
113 if (oldJobStatus != jcr->JobStatus) {
114 - Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
115 + Dmsg3(2, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
116 oldJobStatus, JobStatus);
117 // generate_plugin_event(jcr, bEventStatusChange, NULL);