aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/gun/connection_pool
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-05-07 16:11:48 +0300
committerrinpatch <rinpatch@sdf.org>2020-07-15 15:26:35 +0300
commite94ba05e523d735cd7a357a3aa30e433f60ef9a3 (patch)
treed7878f11b52a7ec8308d9b3e96df4bd8093717bb /lib/pleroma/gun/connection_pool
parent7738fbbaf5a6fcd6a10b4ef0a2dcea731a3d4192 (diff)
downloadpleroma-e94ba05e523d735cd7a357a3aa30e433f60ef9a3.tar.gz
Connection pool: Fix a possible infinite recursion if the pool is exhausted
Diffstat (limited to 'lib/pleroma/gun/connection_pool')
-rw-r--r--lib/pleroma/gun/connection_pool/worker_supervisor.ex14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/pleroma/gun/connection_pool/worker_supervisor.ex b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
index 4b5d10d2a..5cb8d488a 100644
--- a/lib/pleroma/gun/connection_pool/worker_supervisor.ex
+++ b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
@@ -14,16 +14,14 @@ defmodule Pleroma.Gun.ConnectionPool.WorkerSupervisor do
)
end
- def start_worker(opts) do
+ def start_worker(opts, retry \\ false) do
case DynamicSupervisor.start_child(__MODULE__, {Pleroma.Gun.ConnectionPool.Worker, opts}) do
{:error, :max_children} ->
- case free_pool() do
- :ok ->
- start_worker(opts)
-
- :error ->
- :telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts})
- {:error, :pool_full}
+ if retry or free_pool() == :error do
+ :telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts})
+ {:error, :pool_full}
+ else
+ start_worker(opts, true)
end
res ->