From a4ee648c4ad92f667dedba8ebcad6eb21665a73b Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Tue, 21 Apr 2020 14:28:37 +0300 Subject: [PATCH] bugfix for ned opened gun conn --- lib/pleroma/gun/conn.ex | 3 +-- lib/pleroma/pool/connections.ex | 1 + test/pool/connections_test.exs | 10 ++++++++++ 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)