From 8e48dc594ccbdc43d7e4e984a2bdf1627d523bb7 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 5 Mar 2020 00:31:21 +0000 Subject: try reinitializing a broken connection in download_file_lwp git-svn-id: svn://tug.org/texlive/trunk@54084 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLUtils.pm | 43 ++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'Master/tlpkg/TeXLive') diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index ae4c2c282ef..14de29c8f4c 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -2790,31 +2790,42 @@ sub download_file { } } + sub _download_file_lwp { my ($url, $dest) = @_; - if (defined($::tldownload_server) && $::tldownload_server->enabled) { - debug("persistent connection set up, trying to get $url (for $dest)\n"); - my $ret = $::tldownload_server->get_file($url, $dest); - if ($ret) { - ddebug("downloading file via persistent connection succeeded\n"); - return $ret; - } else { - debug("TLUtils::download_file: persistent connection ok," - . " but download failed: $url\n"); - debug("TLUtils::download_file: retrying with wget.\n"); + if (!defined($::tldownload_server)) { + ddebug("::tldownload_server not defined\n"); + return(0); + } + if (!$::tldownload_server->enabled) { + # try to reinitialize a disabled connection + # disabling happens after 6 failed download trials + # we just re-initialize the connection + if (!setup_persistent_downloads()) { + # setup failed, give up + debug("reinitialization of LWP download failed\n"); + return(0); } + # we don't need to check for ->enabled, because + # setup_persistent_downloads calls TLDownload->new() + # which, if it succeeds, automatically set enabled to 1 + } + # we are still here, so try to download + debug("persistent connection set up, trying to get $url (for $dest)\n"); + my $ret = $::tldownload_server->get_file($url, $dest); + if ($ret) { + ddebug("downloading file via persistent connection succeeded\n"); + return $ret; } else { - if (!defined($::tldownload_server)) { - ddebug("::tldownload_server not defined\n"); - } else { - ddebug("::tldownload_server->enabled is not set\n"); - } - debug("persistent connection not set up\n"); + debug("TLUtils::download_file: persistent connection ok," + . " but download failed: $url\n"); + debug("TLUtils::download_file: retrying with other downloaders.\n"); } # if we are still here, download with LWP didn't succeed. return(0); } + sub _download_file_program { my ($url, $dest, $type) = @_; if (win32()) { -- cgit v1.2.3