SVN: toys/rsget.pl/RSGet/Dispatch.pm
sparky
sparky at pld-linux.org
Fri Oct 9 18:29:30 CEST 2009
Author: sparky
Date: Fri Oct 9 18:29:30 2009
New Revision: 10738
Modified:
toys/rsget.pl/RSGet/Dispatch.pm
Log:
- added max_slots option
Modified: toys/rsget.pl/RSGet/Dispatch.pm
==============================================================================
--- toys/rsget.pl/RSGet/Dispatch.pm (original)
+++ toys/rsget.pl/RSGet/Dispatch.pm Fri Oct 9 18:29:30 2009
@@ -5,6 +5,10 @@
use RSGet::Tools;
set_rev qq$Id$;
+def_settings(
+ max_slots => [ "Number of slots (per IP) to use if getter has no limitation.", 8, qr/0*[1-9]\d*/ ],
+);
+
our %downloading;
our %checking;
our %resolving;
@@ -105,6 +109,20 @@
RSGet::FileList::update();
}
+sub get_slots
+{
+ my $cmd = shift;
+ my $suggested = shift;
+ return setting( "max_slots" ) if $cmd eq "check";
+ unless ( defined $suggested ) {
+ return $cmd eq "get" ? 1 : 5;
+ }
+ return 0 + $suggested if $suggested =~ /^\d+$/;
+ return setting( "max_slots" ) if lc $suggested eq "max";
+ warn "Invalid slots declaration: $suggested\n" if verbose( 1 );
+ return 1;
+}
+
sub run
{
my ( $cmd, $uri, $getter, $options ) = @_;
@@ -118,7 +136,7 @@
return $w if defined $w;
my $pkg = $getter->{pkg};
- my $outif = find_free_if( $pkg, $working, ($cmd eq "get" ? ($getter->{slots} || 1) : 5) );
+ my $outif = find_free_if( $pkg, $working, get_slots( $cmd, $getter->{slots} ) );
return unless defined $outif;
my $obj = RSGet::Get::new( $pkg, $cmd, $uri, $options, $outif );
More information about the pld-cvs-commit
mailing list