diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-16 16:23:49 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-16 16:23:49 +0300 |
commit | bf474ca3c154544b54720ea23c06191e68f32522 (patch) | |
tree | 25f5816e40c4b697d32c91aa38eb05b6e2c65abd | |
parent | 35471205f862fa069c6d87aefc1d827c9fab6e08 (diff) | |
download | pleroma-bf474ca3c154544b54720ea23c06191e68f32522.tar.gz |
fix
-rw-r--r-- | lib/pleroma/pool/connections.ex | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex index 16aa80548..91102faf7 100644 --- a/lib/pleroma/pool/connections.ex +++ b/lib/pleroma/pool/connections.ex @@ -167,28 +167,30 @@ defmodule Pleroma.Pool.Connections do c1.crf <= c2.crf and c1.last_reference <= c2.last_reference end - @impl true - def handle_info({:gun_up, conn_pid, _protocol}, state) do + defp find_conn_from_gun_info(conns, pid) do # 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 + try do + %{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(pid) + host = + case :inet.ntoa(host) do + {:error, :einval} -> host + ip -> ip + end + + key = "#{scheme}:#{host}:#{port}" + find_conn(conns, pid, key) + rescue + MatcheError -> find_conn(conns, pid) + end + end + + @impl true + def handle_info({:gun_up, conn_pid, _protocol}, state) do state = - with {true, key} <- {Process.alive?(conn_pid), key} do + with {key, conn} <- find_conn_from_gun_info(state.conns, conn_pid), + {true, key} <- {Process.alive?(conn_pid), key} do put_in(state.conns[key], %{ conn | gun_state: :up, |