]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.34.6/1.34.6-deadlock.patch
Cleanup patches a bit
[bacula/bacula] / bacula / patches / 1.34.6 / 1.34.6-deadlock.patch
1
2  This patch fixes two problems: 1. A deadlock between the job
3  queue scheduler and the watchdog thread. 2. A bad initialization
4  of the watchdog queue which could cause memory corruption. It also
5  reduces the watchdog granularity from 1 second to 10 seconds.
6
7  Apply the patch to Bacula 1.34.6 (probably any 1.34.x version) with:
8
9  cd <bacula-source>
10  patch -p0 <1.34.6-deadlock.patch
11  make
12  ...
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     9 Aug 2004 06:08:08 -0000
22 @@ -501,8 +501,10 @@
23             jcr->db = NULL;
24          }
25           Dmsg1(300, "====== Termination job=%d\n", jcr->JobId);
26 +        V(jq->mutex);                /* release internal job queue lock */
27          free_jcr(jcr);
28          free(je);                    /* release job entry */
29 +        P(jq->mutex);                /* acquire internal job queue lock */
30        }
31        /*
32         * If any job in the wait queue can be run,
33 Index: src/lib/watchdog.c
34 ===================================================================
35 RCS file: /cvsroot/bacula/bacula/src/lib/watchdog.c,v
36 retrieving revision 1.27
37 diff -u -r1.27 watchdog.c
38 --- src/lib/watchdog.c  1 Apr 2004 16:37:01 -0000       1.27
39 +++ src/lib/watchdog.c  9 Aug 2004 06:08:08 -0000
40 @@ -32,11 +32,12 @@
41  
42  /* Exported globals */
43  time_t watchdog_time = 0;            /* this has granularity of SLEEP_TIME */
44 +time_t watchdog_sleep_time = 10;      /* examine things every 10 seconds */
45  
46 -#define SLEEP_TIME 1                 /* examine things every second */
47  
48  /* Forward referenced functions */
49 -static void *watchdog_thread(void *arg);
50 +void *watchdog_thread(void *arg);
51 +
52  static void wd_lock();
53  static void wd_unlock();
54  
55 @@ -71,8 +72,8 @@
56        Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"), 
57             strerror(errstat));
58     }
59 -   wd_queue = new dlist(wd_queue, &dummy->link);
60 -   wd_inactive = new dlist(wd_inactive, &dummy->link);
61 +   wd_queue = new dlist(dummy, &dummy->link);
62 +   wd_inactive = new dlist(dummy, &dummy->link);
63  
64     if ((stat = pthread_create(&wd_tid, NULL, watchdog_thread, NULL)) != 0) {
65        return stat;
66 @@ -214,7 +215,7 @@
67     return ret;
68  }
69  
70 -static void *watchdog_thread(void *arg)
71 +void *watchdog_thread(void *arg)
72  {
73     Dmsg0(400, "NicB-reworked watchdog thread entered\n");
74  
75 @@ -259,7 +260,7 @@
76        }
77        wd_unlock();
78        unlock_jcr_chain();
79 -      bmicrosleep(SLEEP_TIME, 0);
80 +      bmicrosleep(watchdog_sleep_time, 0);
81     }
82  
83     Dmsg0(400, "NicB-reworked watchdog thread exited\n");