From f89bd1444a595b569606679293d2d01b0b7a049e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 9 Jul 2016 03:18:34 +0000 Subject: qspawn: allow configurable limiters And bump the default limit to 32 so we match git-daemon behavior. This shall allow us to configure different levels of concurrency for different repositories and prevent clones of giant repos from stalling service to small repos. --- t/qspawn.t | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/qspawn.t b/t/qspawn.t index 05072e24..9c42e100 100644 --- a/t/qspawn.t +++ b/t/qspawn.t @@ -2,10 +2,12 @@ # License: AGPL-3.0+ use Test::More; use_ok 'PublicInbox::Qspawn'; + +my $limiter = PublicInbox::Qspawn::Limiter->new(1); { my $x = PublicInbox::Qspawn->new([qw(true)]); my $run = 0; - $x->start(sub { + $x->start($limiter, sub { my ($rpipe) = @_; is(0, sysread($rpipe, my $buf, 1), 'read zero bytes'); ok(!$x->finish, 'no error on finish'); @@ -17,7 +19,7 @@ use_ok 'PublicInbox::Qspawn'; { my $x = PublicInbox::Qspawn->new([qw(false)]); my $run = 0; - $x->start(sub { + $x->start($limiter, sub { my ($rpipe) = @_; is(0, sysread($rpipe, my $buf, 1), 'read zero bytes from false'); my $err = $x->finish; @@ -30,7 +32,7 @@ use_ok 'PublicInbox::Qspawn'; foreach my $cmd ([qw(sleep 1)], [qw(sh -c), 'sleep 1; false']) { my $s = PublicInbox::Qspawn->new($cmd); my @run; - $s->start(sub { + $s->start($limiter, sub { my ($rpipe) = @_; push @run, 'sleep'; is(0, sysread($rpipe, my $buf, 1), 'read zero bytes'); @@ -39,7 +41,7 @@ foreach my $cmd ([qw(sleep 1)], [qw(sh -c), 'sleep 1; false']) { my @t = map { my $i = $n++; my $x = PublicInbox::Qspawn->new([qw(true)]); - $x->start(sub { + $x->start($limiter, sub { my ($rpipe) = @_; push @run, $i; }); -- cgit v1.2.3-24-ge0c7