Merge branch 'feat/connection-worker-monitor-flush' into 'develop'
ConnectionPool Worker: use monitor flush instead of checking ref See merge request pleroma/pleroma!3002
This commit is contained in:
commit
a4f80e1e74
1 changed files with 9 additions and 16 deletions
|
@ -93,25 +93,18 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
end)
|
||||
|
||||
{ref, state} = pop_in(state.client_monitors[client_pid])
|
||||
# DOWN message can receive right after `remove_client` call and cause worker to terminate
|
||||
state =
|
||||
if is_nil(ref) do
|
||||
state
|
||||
|
||||
Process.demonitor(ref, [:flush])
|
||||
|
||||
timer =
|
||||
if used_by == [] do
|
||||
max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
|
||||
Process.send_after(self(), :idle_close, max_idle)
|
||||
else
|
||||
Process.demonitor(ref)
|
||||
|
||||
timer =
|
||||
if used_by == [] do
|
||||
max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
|
||||
Process.send_after(self(), :idle_close, max_idle)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
%{state | timer: timer}
|
||||
nil
|
||||
end
|
||||
|
||||
{:reply, :ok, state, :hibernate}
|
||||
{:reply, :ok, %{state | timer: timer}, :hibernate}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
Loading…
Reference in a new issue