mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Fix broken connections in pool
This commit is contained in:
parent
7f8746fcd4
commit
202de1436d
1 changed files with 14 additions and 12 deletions
|
@ -1595,7 +1595,9 @@ struct HTTPPool
|
||||||
end
|
end
|
||||||
|
|
||||||
def client(region = nil, &block)
|
def client(region = nil, &block)
|
||||||
pool.connection do |conn|
|
conn = pool.checkout
|
||||||
|
|
||||||
|
begin
|
||||||
if region
|
if region
|
||||||
PROXY_LIST[region]?.try &.sample(40).each do |proxy|
|
PROXY_LIST[region]?.try &.sample(40).each do |proxy|
|
||||||
begin
|
begin
|
||||||
|
@ -1607,17 +1609,17 @@ struct HTTPPool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
response = yield conn
|
||||||
response = yield conn
|
conn.unset_proxy
|
||||||
conn.unset_proxy
|
response
|
||||||
response
|
rescue ex
|
||||||
rescue ex
|
conn = HTTPClient.new(url)
|
||||||
conn = HTTPClient.new(url)
|
conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::UNSPEC
|
||||||
conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::UNSPEC
|
conn.read_timeout = 5.seconds
|
||||||
conn.read_timeout = 5.seconds
|
conn.connect_timeout = 5.seconds
|
||||||
conn.connect_timeout = 5.seconds
|
yield conn
|
||||||
yield conn
|
ensure
|
||||||
end
|
pool.checkin(conn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue