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:
rinpatch 2020-09-16 17:23:05 +03:00
parent 5c4ff5c73c
commit adb1b0282d

View File

@ -93,12 +93,8 @@ def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) 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
else
Process.demonitor(ref)
Process.demonitor(ref, [:flush])
timer =
if used_by == [] do
@ -108,10 +104,7 @@ def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) do
nil
end
%{state | timer: timer}
end
{:reply, :ok, state, :hibernate}
{:reply, :ok, %{state | timer: timer}, :hibernate}
end
@impl true