summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-04-21 14:28:37 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-05-06 13:25:47 +0300
commita4ee648c4ad92f667dedba8ebcad6eb21665a73b (patch)
treeab89b781d8b430ff59ecf7dab8c3780e318af48c
parent779b991e03df673d006071f5867e56a41a19b2bf (diff)
bugfix for ned opened gun conn
-rw-r--r--lib/pleroma/gun/conn.ex3
-rw-r--r--lib/pleroma/pool/connections.ex1
-rw-r--r--test/pool/connections_test.exs10
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/pleroma/gun/conn.ex b/lib/pleroma/gun/conn.ex
index cd25a2e74..a0f110b42 100644
--- a/lib/pleroma/gun/conn.ex
+++ b/lib/pleroma/gun/conn.ex
@@ -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)
}
diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex
index 984057ab9..b4699edf7 100644
--- a/lib/pleroma/pool/connections.ex
+++ b/lib/pleroma/pool/connections.ex
@@ -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
diff --git a/test/pool/connections_test.exs b/test/pool/connections_test.exs
index ad56e582f..a7afb2190 100644
--- a/test/pool/connections_test.exs
+++ b/test/pool/connections_test.exs
@@ -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)