]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix scheduler again
authorKern Sibbald <kern@sibbald.com>
Sat, 13 Mar 2004 09:30:10 +0000 (09:30 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 13 Mar 2004 09:30:10 +0000 (09:30 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1130 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/scheduler.c
bacula/src/dird/ua_output.c
bacula/src/lib/parse_conf.c
bacula/src/version.h

index bb9008b01eab7e18acf389e7cc2e23dd4ccbd6ba..eed6f1d88438c524a5c73682fa16cfaf0804d17b 100644 (file)
@@ -269,13 +269,15 @@ static void find_runs()
 #endif
 
         run_now = bit_is_set(hour, run->hour) &&
-           (bit_is_set(mday, run->mday) || bit_is_set(wday, run->wday)) &&
+           bit_is_set(mday, run->mday) && 
+           bit_is_set(wday, run->wday) &&
            bit_is_set(month, run->month) &&
            bit_is_set(wom, run->wom) &&
            bit_is_set(woy, run->woy);
 
         run_nh = bit_is_set(nh_hour, run->hour) &&
-           (bit_is_set(nh_mday, run->mday) || bit_is_set(nh_wday, run->wday)) &&
+           bit_is_set(nh_mday, run->mday) && 
+           bit_is_set(nh_wday, run->wday) &&
            bit_is_set(nh_month, run->month) &&
            bit_is_set(nh_wom, run->wom) &&
            bit_is_set(nh_woy, run->woy);
index d3a5286c7dc0c912f10dbcff9c91512854552949..ffebf59e9aff94fba2bf5a3397b3ab54731f4b3e 100644 (file)
@@ -466,7 +466,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
    time_t now, tomorrow;
    SCHED *sched;
    struct tm tm;
-   int mday, wday, month, wom, tmday, twday, tmonth, twom, i, hour;
+   int mday, wday, month, wom, tmday, twday, tmonth, twom, i;
    int woy, twoy;
    int tod, tom;
 
@@ -501,29 +501,46 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
       /* 
        * Find runs in next 24 hours
        */
-      tod = (bit_is_set(mday, run->mday) || bit_is_set(wday, run->wday)) && 
-            bit_is_set(month, run->month) && bit_is_set(wom, run->wom) &&
-            bit_is_set(woy, run->woy);
-
-      tom = (bit_is_set(tmday, run->mday) || bit_is_set(twday, run->wday)) &&
-            bit_is_set(tmonth, run->month) && bit_is_set(twom, run->wom) &&
-            bit_is_set(twoy, run->woy);
-
-//    Dmsg2(200, "tod=%d tom=%d\n", tod, tom);
-//    Dmsg2(200, "wom=%d twom=%d\n", wom, twom);
-//    Dmsg1(200, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
+      tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) && 
+           bit_is_set(month, run->month) && bit_is_set(wom, run->wom) &&
+           bit_is_set(woy, run->woy);
+
+      tom = bit_is_set(tmday, run->mday) && bit_is_set(twday, run->wday) &&
+           bit_is_set(tmonth, run->month) && bit_is_set(twom, run->wom) &&
+           bit_is_set(twoy, run->woy);
+
+#ifdef xxx
+      Dmsg2(000, "tod=%d tom=%d\n", tod, tom);
+      Dmsg1(000, "bit_set_mday=%d\n", bit_is_set(mday, run->mday));
+      Dmsg1(000, "bit_set_wday=%d\n", bit_is_set(wday, run->wday));
+      Dmsg1(000, "bit_set_month=%d\n", bit_is_set(month, run->month));
+      Dmsg1(000, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
+      Dmsg1(000, "bit_set_woy=%d\n", bit_is_set(woy, run->woy));
+#endif xxx
       if (tod) {                  /* Jobs scheduled today (next 24 hours) */
+#ifdef xxx
+        char buf[300], num[10];
+         bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour);
+        for (i=0; i<24; i++) {
+           if (bit_is_set(i, run->hour)) {
+               bsnprintf(num, sizeof(num), "%d ", i);
+              bstrncat(buf, num, sizeof(buf));
+           }
+        }
+         bstrncat(buf, "\n", sizeof(buf));
+         Dmsg1(000, "%s", buf);
+#endif 
         /* find time (time_t) job is to be run */
         localtime_r(&now, &tm);
-        hour = 0;
         for (i=tm.tm_hour; i < 24; i++) {
            if (bit_is_set(i, run->hour)) {
               tm.tm_hour = i;
               tm.tm_min = run->minute;
               tm.tm_sec = 0;
               runtime = mktime(&tm);
+               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
               if (runtime > now) {
-                  Dmsg2(100, "Found it level=%d %c\n", run->level, run->level);
+                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
                  return run;         /* found it, return run resource */
               }
            }
@@ -533,21 +550,19 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
 //    Dmsg2(200, "runtime=%d now=%d\n", runtime, now);
       if (tom) {               /* look at jobs scheduled tomorrow */
         localtime_r(&tomorrow, &tm);
-        hour = 0;
         for (i=0; i < 24; i++) {
            if (bit_is_set(i, run->hour)) {
-              hour = i;
-              break;
+              tm.tm_hour = i;
+              tm.tm_min = run->minute;
+              tm.tm_sec = 0;
+              runtime = mktime(&tm);
+               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
+              if (runtime < tomorrow) {
+                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
+                 return run;         /* found it, return run resource */
+              }
            }
         }
-        tm.tm_hour = hour;
-        tm.tm_min = run->minute;
-        tm.tm_sec = 0;
-        runtime = mktime(&tm);
-//       Dmsg2(200, "truntime=%d now=%d\n", runtime, now);
-        if (runtime < tomorrow) {
-           return run;               /* found it, return run resource */
-        }
       }
    } /* end for loop over runs */ 
    /* Nothing found */
index a11f5d6ee19a584950879e1c9d6d5642f488f429..429edf4d9564e73c6510c69a8628a9aa0e4dcd6a 100755 (executable)
@@ -204,7 +204,7 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
    POOLMEM *dest;
    int dest_len;    
 
-   Dmsg2(200, "store_msgs pass=%d code=%d\n", pass, item->code);
+   Dmsg2(300, "store_msgs pass=%d code=%d\n", pass, item->code);
    if (pass == 1) {
       switch (item->code) {
       case MD_STDOUT:
@@ -245,10 +245,10 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
            }
            break;
         }
-         Dmsg1(200, "mail_cmd=%s\n", NPRT(cmd));
+         Dmsg1(300, "mail_cmd=%s\n", NPRT(cmd));
         scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd);
         free_pool_memory(dest);
-         Dmsg0(200, "done with dest codes\n");
+         Dmsg0(300, "done with dest codes\n");
         break;
       case MD_FILE:               /* file */
       case MD_APPEND:             /* append */
@@ -258,13 +258,13 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
         pm_strcpy(&dest, lc->str);
         dest_len = lc->str_len;
         token = lex_get_token(lc, T_ALL);
-         Dmsg1(200, "store_msgs dest=%s:\n", NPRT(dest));
+         Dmsg1(300, "store_msgs dest=%s:\n", NPRT(dest));
         if (token != T_EQUALS) {
             scan_err1(lc, _("expected an =, got: %s"), lc->str); 
         }
         scan_types(lc, (MSGS *)(item->value), item->code, dest, NULL);
         free_pool_memory(dest);
-         Dmsg0(200, "done with dest codes\n");
+         Dmsg0(300, "done with dest codes\n");
         break;
 
       default:
@@ -274,7 +274,7 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
    }
    scan_to_eol(lc);
    set_bit(index, res_all.hdr.item_present);
-   Dmsg0(200, "Done store_msgs\n");
+   Dmsg0(300, "Done store_msgs\n");
 }
 
 /* 
@@ -325,10 +325,10 @@ static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd
       if (lc->ch != ',') {
         break;
       }
-      Dmsg0(200, "call lex_get_token() to eat comma\n");
+      Dmsg0(300, "call lex_get_token() to eat comma\n");
       lex_get_token(lc, T_ALL);         /* eat comma */
    }
-   Dmsg0(200, "Done scan_types()\n");
+   Dmsg0(300, "Done scan_types()\n");
 }
 
 
@@ -461,7 +461,7 @@ void store_defs(LEX *lc, RES_ITEM *item, int index, int pass)
 
    lex_get_token(lc, T_NAME);
    if (pass == 2) {
-     Dmsg2(200, "Code=%d name=%s\n", item->code, lc->str);
+     Dmsg2(300, "Code=%d name=%s\n", item->code, lc->str);
      res = GetResWithName(item->code, lc->str);
      if (res == NULL) {
         scan_err3(lc, _("Missing config Resource \"%s\" referenced on line %d : %s\n"), 
@@ -471,9 +471,9 @@ void store_defs(LEX *lc, RES_ITEM *item, int index, int pass)
 #ifdef xxx
      for (int i=0; item->name;; i++, item++) {
        if (bit_is_set(i, res->item_present)) {
-           Dmsg2(000, "Item %d is present in %s\n", i, res->name);
+           Dmsg2(300, "Item %d is present in %s\n", i, res->name);
        } else {
-           Dmsg2(000, "Item %d is not present in %s\n", i, res->name);
+           Dmsg2(300, "Item %d is not present in %s\n", i, res->name);
        }
      }
      /* ***FIXME **** add code */
@@ -695,12 +695,12 @@ parse_config(char *cf)
    /* Make two passes. The first builds the name symbol table,
     * and the second picks up the items. 
     */
-   Dmsg0(200, "Enter parse_config()\n");
+   Dmsg0(300, "Enter parse_config()\n");
    for (pass=1; pass <= 2; pass++) {
-      Dmsg1(200, "parse_config pass %d\n", pass);
+      Dmsg1(300, "parse_config pass %d\n", pass);
       lc = lex_open_file(lc, cf, NULL);
       while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
-         Dmsg1(150, "parse got token=%s\n", lex_tok_to_str(token));
+         Dmsg1(300, "parse got token=%s\n", lex_tok_to_str(token));
         switch (state) {
            case p_none:
               if (token == T_EOL) {
@@ -739,13 +739,13 @@ parse_config(char *cf)
                            *   scan for = after the keyword  */
                           if (!(items[i].flags & ITEM_NO_EQUALS)) {
                              token = lex_get_token(lc, T_ALL);
-                              Dmsg1 (150, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
+                              Dmsg1 (300, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
                              if (token != T_EQUALS) {
                                  scan_err1(lc, _("expected an equals, got: %s"), lc->str);
                                 /* NOT REACHED */
                              }
                           }
-                           Dmsg1(150, "calling handler for %s\n", items[i].name);
+                           Dmsg1(300, "calling handler for %s\n", items[i].name);
                           /* Call item handler */
                           items[i].handler(lc, &items[i], i, pass);
                           i = -1;
@@ -753,8 +753,8 @@ parse_config(char *cf)
                        }
                     }
                     if (i >= 0) {
-                        Dmsg2(150, "level=%d id=%s\n", level, lc->str);
-                        Dmsg1(150, "Keyword = %s\n", lc->str);
+                        Dmsg2(300, "level=%d id=%s\n", level, lc->str);
+                        Dmsg1(300, "Keyword = %s\n", lc->str);
                         scan_err1(lc, _("Keyword \"%s\" not permitted in this resource.\n"
                            "Perhaps you left the trailing brace off of the previous resource."), lc->str);
                        /* NOT REACHED */
@@ -764,7 +764,7 @@ parse_config(char *cf)
                  case T_EOB:
                     level--;
                     state = p_none;
-                     Dmsg0(150, "T_EOB => define new resource\n");
+                     Dmsg0(300, "T_EOB => define new resource\n");
                     save_resource(res_type, items, pass);  /* save resource */
                     break;
 
@@ -793,7 +793,7 @@ parse_config(char *cf)
       }
       lc = lex_close_file(lc);
    }
-   Dmsg0(200, "Leave parse_config()\n");
+   Dmsg0(300, "Leave parse_config()\n");
 }
 
 /*********************************************************************
index 9011df864823e191017d670b0c99ccc53d10cc6c..0bdfdbb83d75908036c8ba45be02ac4a7e2106c8 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.4"
 #define VSTRING "1"
-#define BDATE   "12 Mar 2004"
-#define LSMDATE "12Mar04"
+#define BDATE   "13 Mar 2004"
+#define LSMDATE "13Mar04"
 
 /* Debug flags */
 #undef  DEBUG