]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/3.0.2-Fix-seg-fault-in-SD-bug-1371.patch
Added preliminary AFS acl support. The code may need some testing on a real AFS enabl...
[bacula/bacula] / bacula / patches / 3.0.2-Fix-seg-fault-in-SD-bug-1371.patch
1 From 47110b209cb516100d4e3af861b18d5836a585e6 Mon Sep 17 00:00:00 2001
2 From: Kern Sibbald <kern@sibbald.com>
3 Date: Thu, 10 Sep 2009 15:28:59 +0200
4 Subject: [PATCH] Fix seg fault in SD bug #1371
5
6 ---
7  bacula/src/lib/message.c |   17 +++++++++++------
8  1 files changed, 11 insertions(+), 6 deletions(-)
9
10 diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c
11 index 7acf744..bc527a7 100644
12 --- a/bacula/src/lib/message.c
13 +++ b/bacula/src/lib/message.c
14 @@ -1,7 +1,7 @@
15  /*
16     Bacula® - The Network Backup Solution
17  
18 -   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
19 +   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
20  
21     The main author of Bacula is Kern Sibbald, with contributions from
22     many others, a complete list can be found in the file AUTHORS.
23 @@ -69,8 +69,8 @@ void create_jcr_key();
24  
25  /* Static storage */
26  
27 -/* Used to allow only one thread close the daemon messages at a time */
28 -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
29 +/* Allow only one thread to tweak d->fd at a time */
30 +static pthread_mutex_t fides_mutex = PTHREAD_MUTEX_INITIALIZER;
31  static MSGS *daemon_msgs;              /* global messages */
32  static char *catalog_db = NULL;       /* database type */
33  static void (*message_callback)(int type, char *msg) = NULL;
34 @@ -421,7 +421,6 @@ void close_msg(JCR *jcr)
35  
36     if (jcr == NULL) {                /* NULL -> global chain */
37        msgs = daemon_msgs;
38 -      P(mutex);                       /* only one thread walking the chain */
39     } else {
40        msgs = jcr->jcr_msgs;
41        jcr->jcr_msgs = NULL;
42 @@ -429,6 +428,7 @@ void close_msg(JCR *jcr)
43     if (msgs == NULL) {
44        return;
45     }
46 +   P(fides_mutex);
47     Dmsg1(850, "===Begin close msg resource at %p\n", msgs);
48     cmd = get_pool_memory(PM_MESSAGE);
49     for (d=msgs->dest_chain; d; ) {
50 @@ -512,13 +512,12 @@ rem_temp_file:
51        }
52        d = d->next;                    /* point to next buffer */
53     }
54 +   V(fides_mutex);
55     free_pool_memory(cmd);
56     Dmsg0(850, "Done walking message chain.\n");
57     if (jcr) {
58        free_msgs_res(msgs);
59        msgs = NULL;
60 -   } else {
61 -      V(mutex);
62     }
63     Dmsg0(850, "===End close msg resource\n");
64  }
65 @@ -737,6 +736,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
66               case MD_MAIL_ON_ERROR:
67               case MD_MAIL_ON_SUCCESS:
68                  Dmsg1(850, "MAIL for following msg: %s", msg);
69 +                P(fides_mutex);
70                  if (!d->fd) {
71                     POOLMEM *name = get_pool_memory(PM_MESSAGE);
72                     make_unique_mail_filename(jcr, name, d);
73 @@ -748,6 +748,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
74                              be.bstrerror());
75                        d->fd = NULL;
76                        free_pool_memory(name);
77 +                      V(fides_mutex);
78                        break;
79                     }
80                     d->mail_filename = name;
81 @@ -758,6 +759,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
82                     d->max_len = len;      /* keep max line length */
83                  }
84                  fputs(msg, d->fd);
85 +                V(fides_mutex);
86                  break;
87               case MD_APPEND:
88                  Dmsg1(850, "APPEND for following msg: %s", msg);
89 @@ -767,7 +769,9 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
90                  Dmsg1(850, "FILE for following msg: %s", msg);
91                  mode = "w+b";
92  send_to_file:
93 +                P(fides_mutex);
94                  if (!d->fd && !open_dest_file(jcr, d, mode)) {
95 +                   V(fides_mutex);
96                     break;
97                  }
98                  fputs(dt, d->fd);
99 @@ -781,6 +785,7 @@ send_to_file:
100                        fputs(msg, d->fd);
101                     }
102                  }
103 +                V(fides_mutex);
104                  break;
105               case MD_DIRECTOR:
106                  Dmsg1(850, "DIRECTOR for following msg: %s", msg);
107 -- 
108 1.6.4.2
109