texlive[54123] Master/tlpkg/TeXLive: LWP - re-establish connection in

commits+preining at tug.org commits+preining at tug.org
Fri Mar 6 01:59:56 CET 2020


Revision: 54123
          http://tug.org/svn/texlive?view=revision&revision=54123
Author:   preining
Date:     2020-03-06 01:59:56 +0100 (Fri, 06 Mar 2020)
Log Message:
-----------
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)

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLConfig.pm
    trunk/Master/tlpkg/TeXLive/TLDownload.pm
    trunk/Master/tlpkg/TeXLive/TLUtils.pm

Modified: trunk/Master/tlpkg/TeXLive/TLConfig.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLConfig.pm	2020-03-05 23:55:20 UTC (rev 54122)
+++ trunk/Master/tlpkg/TeXLive/TLConfig.pm	2020-03-06 00:59:56 UTC (rev 54123)
@@ -46,6 +46,8 @@
     %TLPDBSettings
     %TLPDBConfigs
     $NetworkTimeout
+    $MaxLWPErrors
+    $MaxLWPReinitCount
     $PartialEngineSupport
     $F_OK $F_WARNING $F_ERROR $F_NOPOSTACTION
     $ChecksumLength
@@ -93,6 +95,10 @@
 
 # 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";

Modified: trunk/Master/tlpkg/TeXLive/TLDownload.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLDownload.pm	2020-03-05 23:55:20 UTC (rev 54122)
+++ trunk/Master/tlpkg/TeXLive/TLDownload.pm	2020-03-06 00:59:56 UTC (rev 54123)
@@ -20,8 +20,6 @@
   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 @@
 {
   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 @@
   $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 @@
   my $self = shift;
   $self->{'enabled'} = 0;
 }
+sub initcount
+{
+  my $self = shift;
+  return $self->{'initcount'};
+}
 sub errorcount
 {
   my $self = shift;
@@ -110,7 +120,7 @@
   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

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2020-03-05 23:55:20 UTC (rev 54122)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2020-03-06 00:59:56 UTC (rev 54123)
@@ -3853,7 +3853,16 @@
 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 {



More information about the tex-live-commits mailing list.