]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird.c
Server address binding + bscan updates -- see kes25Sep02
[bacula/bacula] / bacula / src / dird / dird.c
index 8de6fce6c3ba835d9e021acebeb9dcb6eb8d75d6..7401a340c6ea00e772372d2d2d49923074438c1b 100644 (file)
@@ -43,7 +43,7 @@ extern void term_scheduler();
 extern void term_ua_server();
 extern int do_backup(JCR *jcr);
 extern void backup_cleanup(void);
-extern void start_UA_server(int port);
+extern void start_UA_server(char *addr, int port);
 extern void run_job(JCR *jcr);
 extern void init_job_server(int max_workers);
 
@@ -166,7 +166,7 @@ int main (int argc, char *argv[])
    parse_config(configfile);
 
    if (!check_resources()) {
-      Emsg1(M_ABORT, 0, "Please correct configuration file: %s\n", configfile);
+      Jmsg(NULL, M_ERROR_TERM, 0, "Please correct configuration file: %s\n", configfile);
    }
 
    if (test_config) {
@@ -190,8 +190,11 @@ int main (int argc, char *argv[])
 
    init_console_msg(working_directory);
 
+   set_thread_concurrency(director->MaxConcurrentJobs * 2 +
+      4 /* UA */ + 4 /* sched+watchdog+jobsvr+misc */);
+
    Dmsg0(200, "Start UA server\n");
-   start_UA_server(director->DIRport);
+   start_UA_server(director->DIRaddr, director->DIRport);
 
    start_watchdog();                 /* start network watchdog thread */
 
@@ -265,7 +268,7 @@ static void reload_config(int sig)
 
    Dmsg0(200, "check_resources()\n");
    if (!check_resources()) {
-      Emsg1(M_ABORT, 0, _("Please correct configuration file: %s\n"), configfile);
+      Jmsg(NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
    }
 
    /* Reset globals */
@@ -296,51 +299,51 @@ static int check_resources()
    job = (JOB *)GetNextRes(R_JOB, NULL);
    director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
    if (!director) {
-      Emsg1(M_FATAL, 0, _("No Director resource defined in %s\n\
+      Jmsg(NULL, M_FATAL, 0, _("No Director resource defined in %s\n\
 Without that I don't know who I am :-(\n"), configfile);
       OK = FALSE;
    } else {
       if (!director->working_directory) {
-         Emsg0(M_FATAL, 0, _("No working directory specified. Cannot continue.\n"));
+         Jmsg(NULL, M_FATAL, 0, _("No working directory specified. Cannot continue.\n"));
         OK = FALSE;
       }       
       working_directory = director->working_directory;
       if (!director->messages) {       /* If message resource not specified */
         director->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
         if (!director->messages) {
-            Emsg1(M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile);
+            Jmsg(NULL, M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile);
            OK = FALSE;
         }
       }
       if (GetNextRes(R_DIRECTOR, (RES *)director) != NULL) {
-         Emsg1(M_FATAL, 0, _("Only one Director resource permitted in %s\n"),
+         Jmsg(NULL, M_FATAL, 0, _("Only one Director resource permitted in %s\n"),
            configfile);
         OK = FALSE;
       } 
    }
 
    if (!job) {
-      Emsg1(M_FATAL, 0, _("No Job records defined in %s\n"), configfile);
+      Jmsg(NULL, M_FATAL, 0, _("No Job records defined in %s\n"), configfile);
       OK = FALSE;
    }
    for (job=NULL; (job = (JOB *)GetNextRes(R_JOB, (RES *)job)); ) {
       if (!job->client) {
-         Emsg1(M_FATAL, 0, _("No Client record defined for job %s\n"), job->hdr.name);
+         Jmsg(NULL, M_FATAL, 0, _("No Client record defined for job %s\n"), job->hdr.name);
         OK = FALSE;
       }
-      if (!job->fs) {
-         Emsg1(M_FATAL, 0, _("No FileSet record defined for job %s\n"), job->hdr.name);
+      if (!job->fileset) {
+         Jmsg(NULL, M_FATAL, 0, _("No FileSet record defined for job %s\n"), job->hdr.name);
         OK = FALSE;
       }
       if (!job->storage && job->JobType != JT_VERIFY) {
-         Emsg1(M_FATAL, 0, _("No Storage resource defined for job %s\n"), job->hdr.name);
+         Jmsg(NULL, M_FATAL, 0, _("No Storage resource defined for job %s\n"), job->hdr.name);
         OK = FALSE;
       }
       if (!job->pool) {
-         Emsg1(M_FATAL, 0, _("No Pool resource defined for job %s\n"), job->hdr.name);
+         Jmsg(NULL, M_FATAL, 0, _("No Pool resource defined for job %s\n"), job->hdr.name);
         OK = FALSE;
       }
-      if (job->client->catalog) {
+      if (job->client && job->client->catalog) {
         CAT *catalog = job->client->catalog;
         B_DB *db;
 
@@ -348,16 +351,25 @@ Without that I don't know who I am :-(\n"), configfile);
          * Make sure we can open catalog, otherwise print a warning
          * message because the server is probably not running.
          */
-        db = db_init_database(catalog->db_name, catalog->db_user,
+        db = db_init_database(NULL, catalog->db_name, catalog->db_user,
                            catalog->db_password);
         if (!db_open_database(db)) {
-            Emsg1(M_FATAL,  0, "%s", db_strerror(db));
+            Jmsg(NULL, M_FATAL,  0, "%s", db_strerror(db));
+        } else {
+           /* If a pool is defined for this job, create the pool DB       
+            *  record if it is not already created. 
+            */
+           if (job->pool) {
+              create_pool(db, job->pool);
+           }
+           db_close_database(db);
         }
-        db_close_database(db);
       } else {
-         Emsg1(M_FATAL, 0, _("No Catalog resource defined for client %s\n"), 
+        if (job->client) {
+            Jmsg(NULL, M_FATAL, 0, _("No Catalog resource defined for client %s\n"), 
               job->client->hdr.name);
-        OK = FALSE;
+           OK = FALSE;
+        }
       }
    }