From: Marco van Wieringen Date: Tue, 6 Nov 2012 14:22:26 +0000 (+0100) Subject: Fix bug #1943 no message storage on closed database connection. X-Git-Tag: Release-7.0.0~84 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9890727d214be9b91ad676e518bdbdfa7f4f4f22;p=bacula%2Fbacula 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. --- 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);