ConnectionPool Worker: use monitor flush instead of checking ref
`:flush` removes the DOWN message if one had arrived, so this check should no longer be necessary.
This commit is contained in:
parent
5c4ff5c73c
commit
adb1b0282d
|
@ -93,25 +93,18 @@ def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) do
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{ref, state} = pop_in(state.client_monitors[client_pid])
|
{ref, state} = pop_in(state.client_monitors[client_pid])
|
||||||
# DOWN message can receive right after `remove_client` call and cause worker to terminate
|
|
||||||
state =
|
Process.demonitor(ref, [:flush])
|
||||||
if is_nil(ref) do
|
|
||||||
state
|
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
|
else
|
||||||
Process.demonitor(ref)
|
nil
|
||||||
|
|
||||||
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}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
{:reply, :ok, state, :hibernate}
|
{:reply, :ok, %{state | timer: timer}, :hibernate}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
Loading…
Reference in New Issue