2 This patch fixes two bugs in the job queue scheduling:
3 1. It clears the SD status when rescheduling a job so that
4 the correct status will be displayed by the Director.
5 2. When starting a reschedule thread, it decrements the jcr
6 use_count so that the job will not become a zombie.
8 Apply it to 1.34.6 (possibly to earlier versions with):
11 patch -p0 <1.34.6-resched.patch
15 Index: src/dird/jobq.c
16 ===================================================================
17 RCS file: /cvsroot/bacula/bacula/src/dird/jobq.c,v
18 retrieving revision 1.19
20 --- src/dird/jobq.c 1 Jun 2004 20:10:04 -0000 1.19
21 +++ src/dird/jobq.c 1 Sep 2004 17:22:51 -0000
23 Dmsg0(300, "Enter sched_wait.\n");
25 time_t wtime = jcr->sched_time - time(NULL);
26 + set_jcr_job_status(jcr, JS_WaitStartTime);
27 /* Wait until scheduled time arrives */
28 if (wtime > 0 && verbose) {
29 Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"),
31 - set_jcr_job_status(jcr, JS_WaitStartTime);
33 /* Check every 30 seconds if canceled */
36 sched_pkt = (wait_pkt *)malloc(sizeof(wait_pkt));
39 + jcr->use_count--; /* release our use of jcr */
40 stat = pthread_create(&id, &jq->attr, sched_wait, (void *)sched_pkt);
41 if (stat != 0) { /* thread not created */
42 Jmsg1(jcr, M_ERROR, 0, "pthread_thread_create: ERR=%s\n", strerror(stat));
43 - jcr->use_count--; /* release jcr */
48 Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job,
49 (int)jcr->job->RescheduleInterval);
50 jcr->JobStatus = JS_Created; /* force new status */
51 + jcr->SDJobStatus = 0;
52 dird_free_jcr(jcr); /* partial cleanup old stuff */
53 if (jcr->JobBytes == 0) {
54 Dmsg1(300, "Requeue job=%d\n", jcr->JobId);
58 Dmsg1(300, "====== Termination job=%d\n", jcr->JobId);
59 + V(jq->mutex); /* release internal job queue lock */
61 free(je); /* release job entry */
62 + P(jq->mutex); /* acquire internal job queue lock */
65 * If any job in the wait queue can be run,