]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird.c
ebl Modify disk-changer to check if slot contains something before
[bacula/bacula] / bacula / src / dird / dird.c
index ea0a6987e589b5eaf3edaab4b5c3e56b0eb3aa8d..cba298e56cb624b7b21dc3b9cc4d8671cb6b4619 100644 (file)
@@ -64,7 +64,8 @@ void init_device_resources();
 static char *runjob = NULL;
 static int background = 1;
 static void init_reload(void);
-
+static CONFIG *config;
 /* Globals Exported */
 DIRRES *director;                     /* Director resource */
 int FDConnectTimeout;
@@ -77,6 +78,7 @@ extern int r_first, r_last;           /* first and last resources */
 extern RES_TABLE resources[];
 extern RES **res_head;
 extern RES_ITEM job_items[];
+extern int  res_all_size;
 
 #if defined(_MSC_VER)
 extern "C" { // work around visual compiler mangling variables
@@ -226,7 +228,10 @@ int main (int argc, char *argv[])
       configfile = bstrdup(CONFIG_FILE);
    }
 
-   parse_config(configfile);
+   config = new_config_parser();
+   config->init(configfile, NULL, M_ERROR_TERM, (void *)&res_all, res_all_size,
+                r_first, r_last, resources, res_head);
+   config->parse_config();
 
    if (init_crypto() != 0) {
       Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n"));
@@ -333,6 +338,7 @@ void terminate_dird(int sig)
       exit(1);
    }
    already_here = true;
+   debug_level = 0;                   /* turn off debug */
    stop_watchdog();
    generate_daemon_event(NULL, "Exit");
    unload_plugins();
@@ -349,7 +355,9 @@ void terminate_dird(int sig)
    if (debug_level > 5) {
       print_memory_pool_stats();
    }
-   free_config_resources();
+   config->free_resources();
+   free(config);
+   config = NULL;
    term_ua_server();
    term_msg();                        /* terminate message handler */
    cleanup_crypto();
@@ -475,7 +483,7 @@ void reload_config(int sig)
    }
 
    Dmsg1(100, "Reload_config njobs=%d\n", njobs);
-   reload_table[table].res_table = save_config_resources();
+   reload_table[table].res_table = config->save_resources();
    Dmsg1(100, "Saved old config in table %d\n", table);
 
    ok = parse_config(configfile, 0, M_ERROR);  /* no exit on error */
@@ -490,7 +498,7 @@ void reload_config(int sig)
          Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
          Jmsg(NULL, M_ERROR, 0, _("Resetting previous configuration.\n"));
       }
-      reload_table[rtable].res_table = save_config_resources();
+      reload_table[rtable].res_table = config->save_resources();
       /* Now restore old resoure values */
       int num = r_last - r_first + 1;
       RES **res_tab = reload_table[table].res_table;
@@ -907,12 +915,14 @@ static bool check_catalog()
       /* Loop over all pools, defining/updating them in each database */
       POOL *pool;
       foreach_res(pool, R_POOL) {
-         create_pool(NULL, db, pool, POOL_OP_UPDATE);  /* update request */
-      }
-
-      /* Loop over all pools for updating RecyclePool */
-      foreach_res(pool, R_POOL) {
-         update_pool_recyclepool(NULL, db, pool);
+         /*
+          * If the Pool has a catalog resource create the pool only
+          *   in that catalog.
+          */
+         if (!pool->catalog || pool->catalog == catalog) {
+            create_pool(NULL, db, pool, POOL_OP_UPDATE);  /* update request */
+            update_pool_recyclepool(NULL, db, pool);
+         }
       }
 
       STORE *store;