]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix bug #1943 no message storage on closed database connection.
authorMarco van Wieringen <mvw@planets.elm.net>
Tue, 6 Nov 2012 14:22:26 +0000 (15:22 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:51:02 +0000 (14:51 +0200)
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

index e2fd3e416bba31e295995a93a362c91e33e33ebd..fb3c45eaff4bcaaa8a75a53d31c9d72977323d02 100644 (file)
@@ -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);