summaryrefslogtreecommitdiffstats
path: root/perl-install/ftp.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-02-06 18:50:57 +0000
committerFrancois Pons <fpons@mandriva.com>2001-02-06 18:50:57 +0000
commitf3e3657aea05d9fc8047d8710a6e826fb77eb3b5 (patch)
tree6a8486cfbdb38937e96678158f66f3b3fc023d16 /perl-install/ftp.pm
parentab79ffa49720328bdf9e44b842e7b015e7835cfd (diff)
downloaddrakx-f3e3657aea05d9fc8047d8710a6e826fb77eb3b5.tar
drakx-f3e3657aea05d9fc8047d8710a6e826fb77eb3b5.tar.gz
drakx-f3e3657aea05d9fc8047d8710a6e826fb77eb3b5.tar.bz2
drakx-f3e3657aea05d9fc8047d8710a6e826fb77eb3b5.tar.xz
drakx-f3e3657aea05d9fc8047d8710a6e826fb77eb3b5.zip
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 ?
Diffstat (limited to 'perl-install/ftp.pm')
-rw-r--r--perl-install/ftp.pm15
1 files changed, 10 insertions, 5 deletions
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;
}