fix
This commit is contained in:
parent
35471205f8
commit
bf474ca3c1
@ -167,28 +167,30 @@ defp sort_conns({_, c1}, {_, c2}) do
|
|||||||
c1.crf <= c2.crf and c1.last_reference <= c2.last_reference
|
c1.crf <= c2.crf and c1.last_reference <= c2.last_reference
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
defp find_conn_from_gun_info(conns, pid) do
|
||||||
def handle_info({:gun_up, conn_pid, _protocol}, state) do
|
|
||||||
# TODO: temp fix for gun MatchError https://github.com/ninenines/gun/issues/222
|
# TODO: temp fix for gun MatchError https://github.com/ninenines/gun/issues/222
|
||||||
# TODO: REMOVE LATER
|
# TODO: REMOVE LATER
|
||||||
{key, conn} =
|
try do
|
||||||
try do
|
%{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(pid)
|
||||||
%{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(conn_pid)
|
|
||||||
|
|
||||||
host =
|
host =
|
||||||
case :inet.ntoa(host) do
|
case :inet.ntoa(host) do
|
||||||
{:error, :einval} -> host
|
{:error, :einval} -> host
|
||||||
ip -> ip
|
ip -> ip
|
||||||
end
|
end
|
||||||
|
|
||||||
key = "#{scheme}:#{host}:#{port}"
|
key = "#{scheme}:#{host}:#{port}"
|
||||||
find_conn(state.conns, conn_pid, key)
|
find_conn(conns, pid, key)
|
||||||
rescue
|
rescue
|
||||||
MatcheError -> find_conn(state.conns, conn_pid)
|
MatcheError -> find_conn(conns, pid)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def handle_info({:gun_up, conn_pid, _protocol}, state) do
|
||||||
state =
|
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], %{
|
put_in(state.conns[key], %{
|
||||||
conn
|
conn
|
||||||
| gun_state: :up,
|
| gun_state: :up,
|
||||||
|
Loading…
Reference in New Issue
Block a user