summaryrefslogtreecommitdiff
path: root/Master
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
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')
-rw-r--r--Master/tlpkg/TeXLive/TLConfig.pm6
-rw-r--r--Master/tlpkg/TeXLive/TLDownload.pm28
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm11
3 files changed, 35 insertions, 10 deletions
diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm
index 98867b23093..b2ec57215c7 100644
--- a/Master/tlpkg/TeXLive/TLConfig.pm
+++ b/Master/tlpkg/TeXLive/TLConfig.pm
@@ -46,6 +46,8 @@ BEGIN {
%TLPDBSettings
%TLPDBConfigs
$NetworkTimeout
+ $MaxLWPErrors
+ $MaxLWPReinitCount
$PartialEngineSupport
$F_OK $F_WARNING $F_ERROR $F_NOPOSTACTION
$ChecksumLength
@@ -93,6 +95,10 @@ our $BlockSize = 4096;
# timeout for network connections (wget, LWP) in seconds
our $NetworkTimeout = 30;
+# number of errors during an LWP session until it is marked as disabled
+our $MaxLWPErrors = 5;
+# max number of times we reenable LWP after it was disabled
+our $MaxLWPReinitCount = 10;
our $Archive = "archive";
our $TeXLiveServerURL = "http://mirror.ctan.org";
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
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 14de29c8f4c..e78f9001a53 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -3853,7 +3853,16 @@ false.
sub setup_persistent_downloads {
if ($TeXLive::TLDownload::net_lib_avail) {
ddebug("setup_persistent_downloads has net_lib_avail set\n");
- $::tldownload_server = TeXLive::TLDownload->new;
+ if ($::tldownload_server) {
+ if ($::tldownload_server->initcount() > $TeXLive::TLConfig::MaxLWPReinitCount) {
+ debug("stop retrying to initialize LWP after 10 failures\n");
+ return 0;
+ } else {
+ $::tldownload_server->reinit();
+ }
+ } else {
+ $::tldownload_server = TeXLive::TLDownload->new;
+ }
if (!defined($::tldownload_server)) {
ddebug("TLUtils:setup_persistent_downloads: failed to get ::tldownload_server\n");
} else {