]> git.sur5r.net Git - bacula/bacula/commitdiff
Added set_db_type function to set global debug symbol removed when
authorMarco van Wieringen <mvw@planets.elm.net>
Tue, 25 Jan 2011 20:24:38 +0000 (21:24 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 25 Jan 2011 20:35:10 +0000 (21:35 +0100)
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
bacula/src/lib/message.c
bacula/src/lib/protos.h

index 3c2665742f585d565b13c5e1a04198ac7f3a8f44..6eff0089d8548de9f73802bdb5be0315527527f5 100644 (file)
@@ -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;
index bdb05be1eb3d62ca38b81c7b206a99562885e054..b07b8e7b1fb1a555ba3bdfab87916c5d21d311c1 100644 (file)
@@ -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();
 }
 
index 5a7caba7131d5deda8c1684ce696636d51fe03be..8a18b459080884c2550a54858fc0e3e3cba47033 100644 (file)
@@ -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 */