From f3e3657aea05d9fc8047d8710a6e826fb77eb3b5 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Tue, 6 Feb 2001 18:50:57 +0000 Subject: reworked ftp behaviour a bit for cooperative connection (avoid opening and closing connection too fast for each transaction). There seems to be some problem for retrieving twice a package, this cause huge pause between each transaction, the best is to avoid them so ? --- perl-install/ftp.pm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'perl-install/ftp.pm') diff --git a/perl-install/ftp.pm b/perl-install/ftp.pm index 4014eda10..b21058c30 100644 --- a/perl-install/ftp.pm +++ b/perl-install/ftp.pm @@ -30,13 +30,14 @@ sub new { } my $ftp; - while (1) { + foreach (1..10) { $ftp = Net::FTP->new(network::resolv($host), %options) or die; $ftp && $ftp->login($login, $password) and last; - log::l("login failed, sleeping before trying again"); - sleep 10; + log::l("ftp login failed, sleeping before trying again"); + sleep 5 * $_; } + $ftp or die "unable to open ftp connection to $host"; $ftp->binary; $ftp->cwd($prefix); @@ -49,11 +50,14 @@ sub new { sub getFile { my ($f, @para) = @_; - foreach (1..2) { + foreach (1..3) { my ($ftp, $retr) = new(@para ? @para : fromEnv); $$retr->close if $$retr; + $f eq 'XXX' and return; #- special case to force closing connection on CD, really necessary here! $$retr = $ftp->retr($f) and return $$retr; rewindGetFile(); + log::l("ftp get failed, sleeping before trying again"); + sleep 2; } } @@ -69,7 +73,8 @@ sub getFile { sub rewindGetFile() { #- close any existing connection. foreach (values %hosts) { - my ($ftp) = @{$_ || []}; + my ($ftp, $retr) = @{$_ || []}; + $$retr->close if $$retr; $ftp->close() if $ftp; } -- cgit v1.2.1