diff options
author | rinpatch <rinpatch@sdf.org> | 2020-05-06 21:41:34 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-07-15 15:17:27 +0300 |
commit | fffbcffb8c9ce1e96de5d1a5e15005e271deacd4 (patch) | |
tree | 4f0e6ec4bbe85f014264e648b71760c42ab6c82f | |
parent | 58a4f350a8bc361d793cb96442f856362c18f195 (diff) | |
download | pleroma-fffbcffb8c9ce1e96de5d1a5e15005e271deacd4.tar.gz |
Connection Pool: don't enforce pool limits if no new connection needs to be opened
-rw-r--r-- | lib/pleroma/gun/connection_pool.ex | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/pleroma/gun/connection_pool.ex b/lib/pleroma/gun/connection_pool.ex index e6abee69c..ed7ddff81 100644 --- a/lib/pleroma/gun/connection_pool.ex +++ b/lib/pleroma/gun/connection_pool.ex @@ -2,20 +2,20 @@ defmodule Pleroma.Gun.ConnectionPool do @registry __MODULE__ def get_conn(uri, opts) do - case enforce_pool_limits() do - :ok -> - key = "#{uri.scheme}:#{uri.host}:#{uri.port}" + key = "#{uri.scheme}:#{uri.host}:#{uri.port}" - case Registry.lookup(@registry, key) do - # The key has already been registered, but connection is not up yet - [{worker_pid, {nil, _used_by, _crf, _last_reference}}] -> - get_gun_pid_from_worker(worker_pid) + case Registry.lookup(@registry, key) do + # The key has already been registered, but connection is not up yet + [{worker_pid, {nil, _used_by, _crf, _last_reference}}] -> + get_gun_pid_from_worker(worker_pid) - [{worker_pid, {gun_pid, _used_by, _crf, _last_reference}}] -> - GenServer.cast(worker_pid, {:add_client, self(), false}) - {:ok, gun_pid} + [{worker_pid, {gun_pid, _used_by, _crf, _last_reference}}] -> + GenServer.cast(worker_pid, {:add_client, self(), false}) + {:ok, gun_pid} - [] -> + [] -> + case enforce_pool_limits() do + :ok -> # :gun.set_owner fails in :connected state for whatevever reason, # so we open the connection in the process directly and send it's pid back # We trust gun to handle timeouts by itself @@ -33,10 +33,10 @@ defmodule Pleroma.Gun.ConnectionPool do err -> err end - end - :error -> - {:error, :pool_full} + :error -> + {:error, :pool_full} + end end end |