]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #5853 about the incorrect behavior of the "status schedule" limit parameter
authorEric Bollengier <eric@baculasystems.com>
Fri, 10 Jan 2020 08:35:41 +0000 (09:35 +0100)
committerKern Sibbald <kern@sibbald.com>
Fri, 31 Jan 2020 13:58:20 +0000 (14:58 +0100)
As the Schedule are analyzed job per job, the limit must be applied only when the entire
list is computed. Else, we see only the first jobs.

bacula/src/dird/ua_status.c

index 23f56f9c04a4f2d4df035e040d6cb9a84ca779cc..e704657e4b12086fff79ef86d2dec7f49ef4a4a5 100644 (file)
@@ -956,7 +956,15 @@ static void llist_scheduled_jobs(UAContext *ua)
                   break;
                }
             }
-
+            /* If a time= was set, we can skip schedule that are before the
+             * requested time
+             */
+            if (time_set) {
+               if (runtime < now) {
+                  next += 24 * 60 * 60;
+                  continue;
+               }
+            }
             level = job->JobLevel;
             if (run->level) {
                level = run->level;
@@ -975,14 +983,10 @@ static void llist_scheduled_jobs(UAContext *ua)
             list->insert(item, compare);
 
             next += 24 * 60 * 60;   /* Add one day */
-            num_jobs++;
-            if (limit > 0 && num_jobs >= limit) {
-               goto get_out;
-            }
          }
       } /* end loop over run pkts */
    } /* end for loop over resources */
-get_out:
+
    UnlockRes();
    prt_lrunhdr(ua);
    OutputWriter ow(ua->api_opts);
@@ -992,6 +996,12 @@ get_out:
    foreach_rblist(item, list) {
       char dt[MAX_TIME_LENGTH];
       const char *level_ptr;
+
+      num_jobs++;
+      if (limit > 0 && num_jobs > limit) {
+         break;
+      }
+
       bstrftime_dn(dt, sizeof(dt), item->time);
 
       switch (item->job->JobType) {