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
7 bacula/src/lib/message.c | 17 +++++++++++------
8 1 files changed, 11 insertions(+), 6 deletions(-)
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
16 Bacula® - The Network Backup Solution
18 - Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
19 + Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
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();
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)
36 if (jcr == NULL) { /* NULL -> global chain */
38 - P(mutex); /* only one thread walking the chain */
42 @@ -429,6 +428,7 @@ void close_msg(JCR *jcr)
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:
52 d = d->next; /* point to next buffer */
55 free_pool_memory(cmd);
56 Dmsg0(850, "Done walking message chain.\n");
63 Dmsg0(850, "===End close msg resource\n");
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);
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)
76 free_pool_memory(name);
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 */
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);
94 if (!d->fd && !open_dest_file(jcr, d, mode)) {
99 @@ -781,6 +785,7 @@ send_to_file:
106 Dmsg1(850, "DIRECTOR for following msg: %s", msg);