diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-04-30 15:07:21 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-05-06 13:25:50 +0300 |
commit | a16fb7c35c3b556c28b8e7ad708f6129b2aad161 (patch) | |
tree | d6f4bfdfc4bcbb311f8de8c6978a1f0cf0943019 /lib/pleroma/pool/connections.ex | |
parent | 8e4bd2c1cf0e0570d1e3a1180d8b8a25f1425cc2 (diff) | |
download | pleroma-gun-memory-leak.tar.gz |
clean up and test coveragegun-memory-leak
Diffstat (limited to 'lib/pleroma/pool/connections.ex')
-rw-r--r-- | lib/pleroma/pool/connections.ex | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex index 86bb00bc5..87fa50a22 100644 --- a/lib/pleroma/pool/connections.ex +++ b/lib/pleroma/pool/connections.ex @@ -16,21 +16,20 @@ defmodule Pleroma.Pool.Connections do @type seconds :: pos_integer() @type t :: %__MODULE__{ - conns: %{domain() => conn()}, - opts: keyword() + conns: %{domain() => conn()} } - defstruct conns: %{}, opts: [] + defstruct conns: %{} - @spec start_link({atom(), keyword()}) :: {:ok, pid()} - def start_link({name, opts}) do - GenServer.start_link(__MODULE__, opts, name: name) + @spec start_link(atom()) :: {:ok, pid()} + def start_link(name) do + GenServer.start_link(__MODULE__, [], name: name) end @impl true - def init(opts) do + def init(_) do schedule_close_idle_conns() - {:ok, %__MODULE__{conns: %{}, opts: opts}} + {:ok, %__MODULE__{conns: %{}}} end @spec checkin(String.t() | URI.t(), atom()) :: pid() | nil @@ -43,11 +42,8 @@ defmodule Pleroma.Pool.Connections do @spec alive?(atom()) :: boolean() def alive?(name) do - if pid = Process.whereis(name) do - Process.alive?(pid) - else - false - end + pid = Process.whereis(name) + is_pid(pid) and Process.alive?(pid) end @spec get_state(atom()) :: t() |