]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird.c
Keep the same keywords as in previous version
[bacula/bacula] / bacula / src / dird / dird.c
index a4317214617ea3f1b93d497cbb9294b5b47e5207..7cdbbe37d21b1271e0dff83faa2558af4966dead 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -115,7 +115,7 @@ PROG_COPYRIGHT
 "       -dt         print timestamp in debug output\n"
 "       -f          run in foreground (for debugging)\n"
 "       -g          groupid\n"
-"       -m          print kaboom output for debugging)\n"
+"       -m          print kaboom output (for debugging)\n"
 "       -r <job>    run <job> now\n"
 "       -s          no signals\n"
 "       -t          test - read configuration and exit\n"
@@ -329,7 +329,7 @@ int main (int argc, char *argv[])
 
    init_job_server(director->MaxConcurrentJobs);
 
-   dbg_jcr_add_hook(_dbg_print_db); /* used to debug B_DB connexion after fatal signal */
+   dbg_jcr_add_hook(db_debug_print); /* used to debug B_DB connexion after fatal signal */
 
 //   init_device_resources();
 
@@ -447,7 +447,7 @@ static void free_saved_resources(int table)
  */
 static void reload_job_end_cb(JCR *jcr, void *ctx)
 {
-   int reload_id = (int)((long int)ctx);
+   int reload_id = (int)((intptr_t)ctx);
    Dmsg3(100, "reload job_end JobId=%d table=%d cnt=%d\n", jcr->JobId,
       reload_id, reload_table[reload_id].job_count);
    lock_jobs();
@@ -552,7 +552,7 @@ void reload_config(int sig)
        * Hook all active jobs so that they release this table
        */
       foreach_jcr(jcr) {
-         if (jcr->get_JobType() != JT_SYSTEM) {
+         if (jcr->getJobType() != JT_SYSTEM) {
             reload_table[table].job_count++;
             job_end_push(jcr, reload_job_end_cb, (void *)((long int)table));
             njobs++;
@@ -959,6 +959,15 @@ static bool check_catalog(cat_op mode)
          continue;
       }
 
+      /* Check if the SQL library is thread-safe */
+      db_check_backend_thread_safe();
+
+      /* Display a message if the db max_connections is too low */
+      if (!db_check_max_connections(NULL, db, director->MaxConcurrentJobs)) {
+         Pmsg1(000, "Warning, settings problem for Catalog=%s\n", catalog->name());
+         Pmsg1(000, "%s", db_strerror(db));
+      }
+
       /* we are in testing mode, so don't touch anything in the catalog */
       if (mode == CHECK_CONNECTION) {
          db_close_database(NULL, db);
@@ -994,6 +1003,14 @@ static bool check_catalog(cat_op mode)
       CLIENT *client;
       foreach_res(client, R_CLIENT) {
          CLIENT_DBR cr;
+         /* Create clients only if they use the current catalog */
+         if (client->catalog != catalog) {
+            Dmsg3(500, "Skip client=%s with cat=%s not catalog=%s\n",
+                  client->name(), client->catalog->name(), catalog->name());
+            continue;
+         }
+         Dmsg2(500, "create cat=%s for client=%s\n", 
+               client->catalog->name(), client->name());
          memset(&cr, 0, sizeof(cr));
          bstrncpy(cr.Name, client->name(), sizeof(cr.Name));
          db_create_client_record(NULL, db, &cr);
@@ -1015,11 +1032,19 @@ static bool check_catalog(cat_op mode)
          }
          bstrncpy(sr.Name, store->name(), sizeof(sr.Name));
          sr.AutoChanger = store->autochanger;
-         db_create_storage_record(NULL, db, &sr);
+         if (!db_create_storage_record(NULL, db, &sr)) {
+            Jmsg(NULL, M_FATAL, 0, _("Could not create storage record for %s\n"), 
+                 store->name());
+            OK = false;
+         }
          store->StorageId = sr.StorageId;   /* set storage Id */
          if (!sr.created) {                 /* if not created, update it */
             sr.AutoChanger = store->autochanger;
-            db_update_storage_record(NULL, db, &sr);
+            if (!db_update_storage_record(NULL, db, &sr)) {
+               Jmsg(NULL, M_FATAL, 0, _("Could not update storage record for %s\n"),
+                    store->name());
+               OK = false;
+            }
          }
 
          /* tls_require implies tls_enable */