From 401aac438c601132c75663bd8db99885fbb62baa Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 5 Nov 2019 23:17:15 +1000 Subject: Another attempt to tame timeouts. --- apt-panopticon.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'apt-panopticon.lua') diff --git a/apt-panopticon.lua b/apt-panopticon.lua index e1a481f..f81213c 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -265,15 +265,15 @@ checkHEAD = function (host, URL, r, retry) os.execute("sleep " .. math.random(1, 4)) check = "Retry " .. retry .. " " .. check end - if 3 < timeouts then + if 2 <= timeouts then E("too many timeouts! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) return end - if 20 < r then + if 20 <= r then E("too many redirects! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) return end - if 4 < retry then + if 4 <= retry then E("too many retries! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) return end @@ -348,19 +348,21 @@ local checkFiles = function (host, ip, path, file) else I(" Checking IP " .. host .. " -> " .. ip .. " " .. path) for i, s in pairs(referenceDevs) do + local t = timeouts; timeouts = 0 if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/" .. s) end - if 3 < timeouts then return end + t = t + timeouts; timeouts = 0 if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/" .. s) end - if 3 < timeouts then return end + if 4 <= (t + timeouts) then return end end for i, s in pairs(releases) do for j, k in pairs(releaseFiles) do if repoExists(s .. k) then + local t = timeouts; timeouts = 0 if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/merged/dists/" .. s .. k) end - if 3 < timeouts then return end + t = t + timeouts; timeouts = 0 if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/merged/dists/" .. s .. k) end - if 3 < timeouts then return end + if 4 <= (t + timeouts) then return end end end end -- cgit v1.1