From 9890727d214be9b91ad676e518bdbdfa7f4f4f22 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Tue, 6 Nov 2012 15:22:26 +0100 Subject: [PATCH] Fix bug #1943 no message storage on closed database connection. Bacula director crashes if it reaches the max number connections to MySQL server. (Or any other database) as it tries to store the failure to connect to the database in the database over a non connected database connection. Things like mysql_real_escape_string which is used in that code path depend on a connected database connection which we don't have. --- bacula/src/lib/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index e2fd3e416b..fb3c45eaff 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -798,7 +798,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg) switch (d->dest_code) { case MD_CATALOG: char ed1[50]; - if (!jcr || !jcr->db) { + if (!jcr || !jcr->db || !jcr->db->is_connected()) { break; } if (p_sql_query && p_sql_escape) { @@ -806,7 +806,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg) POOLMEM *esc_msg = get_pool_memory(PM_MESSAGE); int len = strlen(msg) + 1; - esc_msg = check_pool_memory_size(esc_msg, len*2+1); + esc_msg = check_pool_memory_size(esc_msg, len * 2 + 1); p_sql_escape(jcr, jcr->db, esc_msg, msg, len); bstrutime(dt, sizeof(dt), mtime); -- 2.39.5