From f8f42e5fae33fc0e5a5500c2594982f84de592a2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Feb 2010 14:36:50 -0500 Subject: [PATCH] parallel: Fix to really avoid running new jobs when load is too high. The conditions were ORed before, which typically made the load limit be ignored since the jobs limit was satisfied. Also, -l 0 makes little sense, so don't really wait for the load to become lower than 0 in that case. --- debian/changelog | 1 + parallel.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index b5d2a7f..fe89fdf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ moreutils (0.39) UNRELEASED; urgency=low * Cap sillyness. Closes: #570815 * parallel: Fix exit code handling when commands are specified after -- * parallel: Make -j 0 do something reasonable (start all jobs at once). + * parallel: Fix to really avoid running new jobs when load is too high. -- Joey Hess Sun, 21 Feb 2010 13:16:10 -0500 diff --git a/parallel.c b/parallel.c index 06f9041..19f341a 100644 --- a/parallel.c +++ b/parallel.c @@ -201,8 +201,9 @@ int main(int argc, char **argv) { getloadavg(&load, 1); - if ((maxjobs == 0 || curjobs < maxjobs) || - (maxload > 0 && load < maxload)) { + if ((maxjobs == 0 || curjobs < maxjobs) && + (maxload <= 0 || load < maxload)) { + if (argsatonce > arglen - argidx) argsatonce = arglen - argidx; exec_child(command, arguments + argidx, -- 2.39.5