/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/* Static storage */
-/* Used to allow only one thread close the daemon messages at a time */
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+/* Allow only one thread to tweak d->fd at a time */
+static pthread_mutex_t fides_mutex = PTHREAD_MUTEX_INITIALIZER;
static MSGS *daemon_msgs; /* global messages */
static char *catalog_db = NULL; /* database type */
static void (*message_callback)(int type, char *msg) = NULL;
if (jcr == NULL) { /* NULL -> global chain */
msgs = daemon_msgs;
- P(mutex); /* only one thread walking the chain */
} else {
msgs = jcr->jcr_msgs;
jcr->jcr_msgs = NULL;
if (msgs == NULL) {
return;
}
+ P(fides_mutex);
Dmsg1(850, "===Begin close msg resource at %p\n", msgs);
cmd = get_pool_memory(PM_MESSAGE);
for (d=msgs->dest_chain; d; ) {
}
d = d->next; /* point to next buffer */
}
+ V(fides_mutex);
free_pool_memory(cmd);
Dmsg0(850, "Done walking message chain.\n");
if (jcr) {
free_msgs_res(msgs);
msgs = NULL;
- } else {
- V(mutex);
}
Dmsg0(850, "===End close msg resource\n");
}
case MD_MAIL_ON_ERROR:
case MD_MAIL_ON_SUCCESS:
Dmsg1(850, "MAIL for following msg: %s", msg);
+ P(fides_mutex);
if (!d->fd) {
POOLMEM *name = get_pool_memory(PM_MESSAGE);
make_unique_mail_filename(jcr, name, d);
be.bstrerror());
d->fd = NULL;
free_pool_memory(name);
+ V(fides_mutex);
break;
}
d->mail_filename = name;
d->max_len = len; /* keep max line length */
}
fputs(msg, d->fd);
+ V(fides_mutex);
break;
case MD_APPEND:
Dmsg1(850, "APPEND for following msg: %s", msg);
Dmsg1(850, "FILE for following msg: %s", msg);
mode = "w+b";
send_to_file:
+ P(fides_mutex);
if (!d->fd && !open_dest_file(jcr, d, mode)) {
+ V(fides_mutex);
break;
}
fputs(dt, d->fd);
fputs(msg, d->fd);
}
}
+ V(fides_mutex);
break;
case MD_DIRECTOR:
Dmsg1(850, "DIRECTOR for following msg: %s", msg);