aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/gun/connection_pool/worker_supervisor.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/gun/connection_pool/worker_supervisor.ex')
-rw-r--r--[-rwxr-xr-x]lib/pleroma/gun/connection_pool/worker_supervisor.ex6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/gun/connection_pool/worker_supervisor.ex b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
index d26a70b..eb83962 100755..100644
--- a/lib/pleroma/gun/connection_pool/worker_supervisor.ex
+++ b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
@@ -18,10 +18,12 @@ defmodule Pleroma.Gun.ConnectionPool.WorkerSupervisor do
)
end
- def start_worker(opts, retry \\ false) do
+ def start_worker(opts, last_attempt \\ false) do
case DynamicSupervisor.start_child(__MODULE__, {Pleroma.Gun.ConnectionPool.Worker, opts}) do
{:error, :max_children} ->
- if retry or free_pool() == :error do
+ funs = [fn -> last_attempt end, fn -> match?(:error, free_pool()) end]
+
+ if Enum.any?(funs, fn fun -> fun.() end) do
:telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts})
{:error, :pool_full}
else