Joey Hess <jo...@debian.org> writes:

> Gergely Nagy wrote:
>> +my $processes=0;
>> +my $max_procs=0;
>
> Wouldn't it be simpler to default $max_procs to 1, rather than the
> current special-cased handling of 0 via $forked etc?

Good point, it would be.

>> +    } else {
>
> Hmm, there is no check for fork having failed. ($pid would be undef)
>
>> +            if (++$processes > 1) {
>> +                    wait;
>> +                    --$processes;
>
> It's impossible for this code block to not run, and it seems to cause
> only one child to run at a time, since $processes will always be
> incremented to 1, the child waited on, and then it decremented again.

Hrm, interesting. I did see 2 dpkg-deb processes run when testing with
ghc..

Right. $processes start with 0, and when the first forks, the if
evaluates to if (1 > 1) which will be false. It will wait on the next
one after that, though, so the parallellism caps at 2, which happened to
be what I was testing with. Ouch.

Off the top of my head, 'if (++$processes >= $max_procs)' should work:
when the number of processes reach $max_procs, it'll wait 'till there's
a slot free.

I'll add fork() error handling and the above change, retest & send an
updated patch.

-- 
|8]



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to