summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-10-25 22:40:20 -0400
committerOmar Roth <omarroth@protonmail.com>2019-10-25 22:40:53 -0400
commit7f8746fcd481a3f75f6a30658e3bfeeff0eb3fbd (patch)
treeb90c22594a20eea5f5dfe0e3d002fb285683e629
parente05a25d701a2b4765028d9f23306098b263e15b9 (diff)
downloadinvidious-7f8746fcd481a3f75f6a30658e3bfeeff0eb3fbd.tar.gz
invidious-7f8746fcd481a3f75f6a30658e3bfeeff0eb3fbd.tar.bz2
invidious-7f8746fcd481a3f75f6a30658e3bfeeff0eb3fbd.zip
Remove invalid connections from pool
-rw-r--r--src/invidious/helpers/utils.cr14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index d0076024..2e802051 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -1607,9 +1607,17 @@ struct HTTPPool
end
end
- response = yield conn
- conn.unset_proxy
- response
+ 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
end
end