summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLDownload.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2020-03-06 00:59:56 +0000
committerNorbert Preining <preining@logic.at>2020-03-06 00:59:56 +0000
commitc4f00a0973191a11fbe509d9afca1ee20085e79e (patch)
treeca88fc47c909c291096a23bb9b6677977bb75a16 /Master/tlpkg/TeXLive/TLDownload.pm
parentc4c10f365c82eeaa96e66d17a05004100d8113ad (diff)
LWP - re-establish connection in case it got disabled
After 5 (TLConfig::LWPMaxErrors) errors, the LWP module is getting disabled. Re-establish a new connection and enable LWP to get higher throughput. To make sure that this doesn't loop, we limit the number of re-enabling to 10 (TLConfig::MaxLWPReinitCount) git-svn-id: svn://tug.org/texlive/trunk@54123 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLDownload.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLDownload.pm28
1 files changed, 19 insertions, 9 deletions
diff --git a/Master/tlpkg/TeXLive/TLDownload.pm b/Master/tlpkg/TeXLive/TLDownload.pm
index 1633add6413..9988f62ee09 100644
--- a/Master/tlpkg/TeXLive/TLDownload.pm
+++ b/Master/tlpkg/TeXLive/TLDownload.pm
@@ -20,8 +20,6 @@ sub module_revision {
return $_modulerevision;
}
-my $MAX_ERRORCOUNT = 5;
-
# since Net::HTTP and Net::FTP are shipped by the same packages
# we only test for Net::HTTP, if that fails, let us know ;-)
our $net_lib_avail = 0;
@@ -41,6 +39,18 @@ sub new
{
my $class = shift;
my $self = {};
+ $self->{'initcount'} = 0;
+ bless $self, $class;
+ $self->reinit();
+ return $self;
+}
+
+
+
+
+sub reinit
+{
+ my $self = shift;
my $ua = LWP::UserAgent->new(
agent => "texlive/lwp",
# use LWP::ConnCache, and keep 1 connection open
@@ -51,13 +61,8 @@ sub new
$self->{'ua'} = $ua;
$self->{'enabled'} = 1;
$self->{'errorcount'} = 0;
- bless $self, $class;
- return $self;
+ $self->{'initcout'} += 1;
}
-
-
-
-
sub enabled
{
my $self = shift;
@@ -80,6 +85,11 @@ sub disable
my $self = shift;
$self->{'enabled'} = 0;
}
+sub initcount
+{
+ my $self = shift;
+ return $self->{'initcount'};
+}
sub errorcount
{
my $self = shift;
@@ -110,7 +120,7 @@ sub get_file {
my ($self,$url,$out,$size) = @_;
#
# automatically disable if error count is getting too big
- if ($self->errorcount > $MAX_ERRORCOUNT) {
+ if ($self->errorcount > $TeXLive::TLConfig::MaxLWPErrors) {
$self->disable;
}
# return if disabled