]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird.c
correct date
[bacula/bacula] / bacula / src / dird / dird.c
index f6f0213c71e661840c1878e3dae49dde855e2499..b4130421222ccb25418d89b9b262928c47c2d9b4 100644 (file)
@@ -97,61 +97,60 @@ int main (int argc, char *argv[])
    textdomain("bacula-dir");
    init_msg(NULL, NULL);             /* initialize message handler */
    daemon_start_time = time(NULL);
-   memset(&last_job, 0, sizeof(last_job));
 
    while ((ch = getopt(argc, argv, "c:d:fg:r:stu:v?")) != -1) {
       switch (ch) {
          case 'c':                    /* specify config file */
-           if (configfile != NULL) {
-              free(configfile);
-           }
-           configfile = bstrdup(optarg);
-           break;
+        if (configfile != NULL) {
+           free(configfile);
+        }
+        configfile = bstrdup(optarg);
+        break;
 
-         case 'd':                    /* set debug level */
-           debug_level = atoi(optarg);
-           if (debug_level <= 0) {
-              debug_level = 1; 
-           }
-            Dmsg1(0, "Debug level = %d\n", debug_level);
-           break;
+      case 'd':                    /* set debug level */
+        debug_level = atoi(optarg);
+        if (debug_level <= 0) {
+           debug_level = 1; 
+        }
+         Dmsg1(0, "Debug level = %d\n", debug_level);
+        break;
 
-         case 'f':                    /* run in foreground */
-           background = FALSE;
-           break;
+      case 'f':                    /* run in foreground */
+        background = FALSE;
+        break;
 
-         case 'g':                    /* set group id */
-           gid = optarg;
-           break;
+      case 'g':                    /* set group id */
+        gid = optarg;
+        break;
 
-         case 'r':                    /* run job */
-           if (runjob != NULL) {
-              free(runjob);
-           }
-           if (optarg) {
-              runjob = bstrdup(optarg);
-           }
-           break;
+      case 'r':                    /* run job */
+        if (runjob != NULL) {
+           free(runjob);
+        }
+        if (optarg) {
+           runjob = bstrdup(optarg);
+        }
+        break;
 
-         case 's':                    /* turn off signals */
-           no_signals = TRUE;
-           break;
+      case 's':                    /* turn off signals */
+        no_signals = TRUE;
+        break;
 
-         case 't':                    /* test config */
-           test_config = TRUE;
-           break;
+      case 't':                    /* test config */
+        test_config = TRUE;
+        break;
 
-         case 'u':                    /* set uid */
-           uid = optarg;
-           break;
+      case 'u':                    /* set uid */
+        uid = optarg;
+        break;
 
-         case 'v':                    /* verbose */
-           verbose++;
-           break;
+      case 'v':                    /* verbose */
+        verbose++;
+        break;
 
-         case '?':
-        default:
-           usage();
+      case '?':
+      default:
+        usage();
 
       }  
    }
@@ -241,7 +240,7 @@ static void terminate_dird(int sig)
    delete_pid_file(director->pid_directory, "bacula-dir",  
                   director->DIRport);
    stop_watchdog();
-   signal(SIGCHLD, SIG_IGN);          /* don't worry about children now */
+// signal(SIGCHLD, SIG_IGN);          /* don't worry about children now */
    term_scheduler();
    if (runjob) {
       free(runjob);
@@ -367,9 +366,12 @@ Without that I don't know who I am :-(\n"), configfile);
         db = db_init_database(NULL, catalog->db_name, catalog->db_user,
                            catalog->db_password, catalog->db_address,
                            catalog->db_port, catalog->db_socket);
-        if (!db_open_database(NULL, db)) {
-            Jmsg(NULL, M_FATAL, 0, _("Could not open %s database \"%s\".\n"),
-                catalog_db, catalog->db_name);
+        if (!db || !db_open_database(NULL, db)) {
+            Jmsg(NULL, M_FATAL, 0, _("Could not open database \"%s\".\n"),
+                catalog->db_name);
+           if (db) {
+               Jmsg(NULL, M_FATAL, 0, _("%s"), db_strerror(db));
+           }
            OK = FALSE;
         } else {
            /* If a pool is defined for this job, create the pool DB       
@@ -387,13 +389,18 @@ Without that I don't know who I am :-(\n"), configfile);
                  cr.MinValue = counter->MinValue;
                  cr.MaxValue = counter->MaxValue;
                  cr.CurrentValue = counter->MinValue;
-                 bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter));
+                 if (counter->WrapCounter) {
+                    bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter));
+                 } else {
+                    cr.WrapCounter[0] = 0;  /* empty string */
+                 }
                  if (db_create_counter_record(NULL, db, &cr)) {
                     counter->CurrentValue = cr.CurrentValue;
                     counter->created = true;
-//                   Dmsg2(000, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue);
+                     Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue);
                  }
-              } else {
+              } 
+              if (!counter->created) {
                  counter->CurrentValue = counter->MinValue;  /* default value */
               }
            }