From: Eric Bollengier Date: Fri, 10 Jan 2020 08:35:41 +0000 (+0100) Subject: Fix #5853 about the incorrect behavior of the "status schedule" limit parameter X-Git-Tag: Release-9.6.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0566ea6d80183b9c0950d0ee0d850b74abd76a5;p=thirdparty%2Fbacula.git Fix #5853 about the incorrect behavior of the "status schedule" limit parameter 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. --- diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 23f56f9c0..e704657e4 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -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) {