forked from AkkomaGang/akkoma
Connection pool: Fix a possible infinite recursion if the pool is exhausted
This commit is contained in:
parent
7738fbbaf5
commit
e94ba05e52
1 changed files with 6 additions and 8 deletions
|
@ -14,16 +14,14 @@ def init(_opts) do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_worker(opts) do
|
def start_worker(opts, retry \\ false) do
|
||||||
case DynamicSupervisor.start_child(__MODULE__, {Pleroma.Gun.ConnectionPool.Worker, opts}) do
|
case DynamicSupervisor.start_child(__MODULE__, {Pleroma.Gun.ConnectionPool.Worker, opts}) do
|
||||||
{:error, :max_children} ->
|
{:error, :max_children} ->
|
||||||
case free_pool() do
|
if retry or free_pool() == :error do
|
||||||
:ok ->
|
:telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts})
|
||||||
start_worker(opts)
|
{:error, :pool_full}
|
||||||
|
else
|
||||||
:error ->
|
start_worker(opts, true)
|
||||||
:telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts})
|
|
||||||
{:error, :pool_full}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
res ->
|
res ->
|
||||||
|
|
Loading…
Reference in a new issue