From 3a6a7ae64f9060977448b926ffc367b3db81e991 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Tue, 25 Jan 2011 21:24:38 +0100 Subject: [PATCH] Added set_db_type function to set global debug symbol removed when doing class based catalog backends. Coding is a bit different as we need get_db_type which needs a bdb class so we have to set it as part of the loop over all catalogs. This way we may set the global variable a couple of times but the code frees the global variable if needed so other then being somewhat overkill no harm is done. --- bacula/src/dird/dird.c | 3 +++ bacula/src/lib/message.c | 14 ++++++++++++++ bacula/src/lib/protos.h | 1 + 3 files changed, 18 insertions(+) diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 3c2665742f..6eff0089d8 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -1113,6 +1113,9 @@ static bool check_catalog(cat_op mode) db_sql_query(db, cleanup_running_job, NULL, NULL); } + /* Set type in global for debugging */ + set_db_type(db_get_type(db)); + db_close_database(NULL, db); } return OK; diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index bdb05be1eb..b07b8e7b1f 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -77,6 +77,7 @@ void create_jcr_key(); /* 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; static FILE *trace_fd = NULL; #if defined(HAVE_WIN32) @@ -222,6 +223,15 @@ void my_name_is(int argc, char *argv[], const char *name) } } +void +set_db_type(const char *name) +{ + if (catalog_db != NULL) { + free(catalog_db); + } + catalog_db = bstrdup(name); +} + /* * Initialize message handler for a daemon or a Job * We make a copy of the MSGS resource passed, so it belows @@ -636,6 +646,10 @@ void term_msg() fclose(trace_fd); trace_fd = NULL; } + if (catalog_db) { + free(catalog_db); + catalog_db = NULL; + } term_last_jobs_list(); } diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 5a7caba713..8a18b45908 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -237,6 +237,7 @@ void init_console_msg (const char *wd); void free_msgs_res (MSGS *msgs); void dequeue_messages (JCR *jcr); void set_trace (int trace_flag); +void set_db_type (const char *name); void register_message_callback(void msg_callback(int type, char *msg)); /* bnet_server.c */ -- 2.39.5