aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-03-16 15:47:25 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-03-16 15:47:25 +0300
commit35471205f862fa069c6d87aefc1d827c9fab6e08 (patch)
treec81c3ea0632ef05a7b38e7148639d10e86e6fa52
parent3805e09b9c2c309f4fcb7654831ab9927c95cfd0 (diff)
downloadpleroma-35471205f862fa069c6d87aefc1d827c9fab6e08.tar.gz
temp fix for `:gun.info` MatchError
-rw-r--r--lib/pleroma/pool/connections.ex27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex
index 772833509..16aa80548 100644
--- a/lib/pleroma/pool/connections.ex
+++ b/lib/pleroma/pool/connections.ex
@@ -169,19 +169,26 @@ defmodule Pleroma.Pool.Connections do
@impl true
def handle_info({:gun_up, conn_pid, _protocol}, state) do
- %{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(conn_pid)
-
- host =
- case :inet.ntoa(host) do
- {:error, :einval} -> host
- ip -> ip
+ # TODO: temp fix for gun MatchError https://github.com/ninenines/gun/issues/222
+ # TODO: REMOVE LATER
+ {key, conn} =
+ try do
+ %{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(conn_pid)
+
+ host =
+ case :inet.ntoa(host) do
+ {:error, :einval} -> host
+ ip -> ip
+ end
+
+ key = "#{scheme}:#{host}:#{port}"
+ find_conn(state.conns, conn_pid, key)
+ rescue
+ MatcheError -> find_conn(state.conns, conn_pid)
end
- key = "#{scheme}:#{host}:#{port}"
-
state =
- with {_key, conn} <- find_conn(state.conns, conn_pid, key),
- {true, key} <- {Process.alive?(conn_pid), key} do
+ with {true, key} <- {Process.alive?(conn_pid), key} do
put_in(state.conns[key], %{
conn
| gun_state: :up,