From: Joey Hess Date: Tue, 23 Feb 2010 19:36:50 +0000 (-0500) Subject: parallel: Fix to really avoid running new jobs when load is too high. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8f42e5fae33fc0e5a5500c2594982f84de592a2;p=moreutils 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. --- 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,