bugfix for ned opened gun conn

This commit is contained in:
Alexander Strizhakov 2020-04-21 14:28:37 +03:00
parent 779b991e03
commit a4ee648c4a
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
3 changed files with 12 additions and 2 deletions

View File

@ -26,7 +26,7 @@ defmodule Pleroma.Gun.Conn do
defstruct conn: nil,
gun_state: :open,
conn_state: :init,
conn_state: :idle,
used_by: [],
last_reference: 0,
crf: 1,
@ -62,7 +62,6 @@ defmodule Pleroma.Gun.Conn do
conn = %Pleroma.Gun.Conn{
conn: conn_pid,
gun_state: :up,
conn_state: :active,
last_reference: :os.system_time(:second)
}

View File

@ -226,6 +226,7 @@ defmodule Pleroma.Pool.Connections do
put_in(state.conns[key], %{
conn
| gun_state: :down,
conn_state: :idle,
retries: conn.retries + 1
})
end

View File

@ -97,6 +97,16 @@ defmodule Pleroma.Pool.ConnectionsTest do
refute Connections.checkin(url, name)
:ok = Conn.open(url, name)
%Connections{
conns: %{
^key => %Conn{
gun_state: :up,
used_by: [],
conn_state: :idle
}
}
} = Connections.get_state(name)
conn = Connections.checkin(url, name)
assert is_pid(conn)
assert Process.alive?(conn)