This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to branch master
in repository dh-make-perl.

commit 2ad9499e96bede8a42092489ba8d868fdc9aea92
Author: Damyan Ivanov <[email protected]>
Date:   Sat Feb 17 08:47:44 2018 +0000

    AptContents: avoid empty cpu allocation slots when distributing multiple 
contents files tor parsing
    
    simply cap the number of cpu slots to the number of files to avoid
    leaving cpu slots without assigned files, which later results in
    callint cat-file with no arguments, leading to hangs reading from STDIN
---
 lib/Debian/AptContents.pm |  2 ++
 t/AptContents.t           | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/lib/Debian/AptContents.pm b/lib/Debian/AptContents.pm
index 4295a91..04792e0 100644
--- a/lib/Debian/AptContents.pm
+++ b/lib/Debian/AptContents.pm
@@ -182,6 +182,8 @@ invocation.
 sub _distribute_files {
     my ( $self, $files, $cpus ) = @_;
 
+    $cpus = scalar(@$files) if scalar(@$files) < $cpus;
+
     return $files unless $cpus > 1;
 
     my @data = map( { file => $_, size => -s $_ }, @$files );
diff --git a/t/AptContents.t b/t/AptContents.t
index 9fd54c1..a7c5282 100755
--- a/t/AptContents.t
+++ b/t/AptContents.t
@@ -29,6 +29,16 @@ eval { Debian::AptContents->new() };
 ok( $@, 'AptContents->new with no homedir dies' );
 like( $@, qr/No homedir given/, 'should say why it died' );
 
+{
+    my @c_files = glob('t/contents/*');
+    my @slots = Debian::AptContents->_distribute_files( \@c_files,
+        scalar(@c_files) + 2 );
+
+    ok( scalar(@slots) == scalar(@c_files),
+        "Distributing files on more CPUs results in no empty slots" )
+        or diag @slots;
+}
+
 my $apt_contents = instance();
 
 isnt( $apt_contents, undef, 'should create' );

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to