]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.34.6/1.34.6-resched.patch
ebl add readme for item20 patch
[bacula/bacula] / bacula / patches / 1.34.6 / 1.34.6-resched.patch
1
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.
7
8  Apply it to 1.34.6 (possibly to earlier versions with):
9
10  cd <bacula-source>
11  patch -p0 <1.34.6-resched.patch
12  make
13  ...
14
15 Index: src/dird/jobq.c
16 ===================================================================
17 RCS file: /cvsroot/bacula/bacula/src/dird/jobq.c,v
18 retrieving revision 1.19
19 diff -u -r1.19 jobq.c
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
22 @@ -160,11 +160,11 @@
23     Dmsg0(300, "Enter sched_wait.\n");
24     free(arg);
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"), 
30          jcr->Job, wtime);
31 -      set_jcr_job_status(jcr, JS_WaitStartTime);
32     }
33     /* Check every 30 seconds if canceled */ 
34     while (wtime > 0) {
35 @@ -217,10 +217,10 @@
36        sched_pkt = (wait_pkt *)malloc(sizeof(wait_pkt));
37        sched_pkt->jcr = jcr;
38        sched_pkt->jq = jq;
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 */
44        }
45        return stat;
46     }
47 @@ -465,6 +465,7 @@
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);
55 @@ -501,8 +502,10 @@
56             jcr->db = NULL;
57          }
58           Dmsg1(300, "====== Termination job=%d\n", jcr->JobId);
59 +        V(jq->mutex);                /* release internal job queue lock */
60          free_jcr(jcr);
61          free(je);                    /* release job entry */
62 +        P(jq->mutex);                /* acquire internal job queue lock */
63        }
64        /*
65         * If any job in the wait queue can be run,