diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-30 12:47:12 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-30 12:47:12 +0300 |
commit | 1fcdcb12a717fa3dbd54a5c3778bd216df6449ad (patch) | |
tree | 701dfc23c7c92ff99784cc3628bf322b2519e88f /lib | |
parent | 2afc7a9112fc11bc51abc2b65aea03d6d5045695 (diff) | |
download | pleroma-1fcdcb12a717fa3dbd54a5c3778bd216df6449ad.tar.gz |
updating gun with bug fix
https://github.com/ninenines/gun/issues/222
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/pool/connections.ex | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex index 91102faf7..4d4ba913c 100644 --- a/lib/pleroma/pool/connections.ex +++ b/lib/pleroma/pool/connections.ex @@ -167,29 +167,20 @@ defmodule Pleroma.Pool.Connections do c1.crf <= c2.crf and c1.last_reference <= c2.last_reference end - 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 - 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 + %{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}" + state = - with {key, conn} <- find_conn_from_gun_info(state.conns, conn_pid), + with {key, conn} <- find_conn(state.conns, conn_pid, key), {true, key} <- {Process.alive?(conn_pid), key} do put_in(state.conns[key], %{ conn |