Invidious is an alternative front-end to YouTube
Fix broken connections in pool
Omar Roth202de1436d81
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.crindex 2e802051..5ddc8375 100644--- a/src/invidious/helpers/utils.cr+++ b/src/invidious/helpers/utils.cr@@ -1595,7 +1595,9 @@ struct HTTPPoolenddef client(region = nil, &block)- pool.connection do |conn|+ conn = pool.checkout++ beginif regionPROXY_LIST[region]?.try &.sample(40).each do |proxy|begin@@ -1607,17 +1609,17 @@ struct HTTPPoolendend- begin- response = yield conn- conn.unset_proxy- response- rescue ex- conn = HTTPClient.new(url)- conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::UNSPEC- conn.read_timeout = 5.seconds- conn.connect_timeout = 5.seconds- yield conn- end+ response = yield conn+ conn.unset_proxy+ response+ rescue ex+ conn = HTTPClient.new(url)+ conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::UNSPEC+ conn.read_timeout = 5.seconds+ conn.connect_timeout = 5.seconds+ yield conn+ ensure+ pool.checkin(conn)endend