gun ConnectionPool: Re-add a missing cast for remove_client
This commit is contained in:
parent
4ce6179dc7
commit
dab1d8c98e
|
@ -45,7 +45,7 @@ defp get_gun_pid_from_worker(worker_pid, register) do
|
||||||
# so instead we use cast + monitor
|
# so instead we use cast + monitor
|
||||||
|
|
||||||
ref = Process.monitor(worker_pid)
|
ref = Process.monitor(worker_pid)
|
||||||
if register, do: GenServer.cast(worker_pid, {:add_client, self(), true})
|
if register, do: GenServer.cast(worker_pid, {:add_client, self()})
|
||||||
|
|
||||||
receive do
|
receive do
|
||||||
{:conn_pid, pid} ->
|
{:conn_pid, pid} ->
|
||||||
|
|
|
@ -36,10 +36,18 @@ def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_cast({:add_client, client_pid, send}, state) do
|
def handle_cast({:add_client, client_pid}, state) do
|
||||||
case handle_call(:add_client, {client_pid, nil}, state) do
|
case handle_call(:add_client, {client_pid, nil}, state) do
|
||||||
{:reply, conn_pid, state, :hibernate} ->
|
{:reply, conn_pid, state, :hibernate} ->
|
||||||
if send, do: send(client_pid, {:conn_pid, conn_pid})
|
send(client_pid, {:conn_pid, conn_pid})
|
||||||
|
{:noreply, state, :hibernate}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def handle_cast({:remove_client, client_pid}, state) do
|
||||||
|
case handle_call(:remove_client, {client_pid, nil}, state) do
|
||||||
|
{:reply, _, state, :hibernate} ->
|
||||||
{:noreply, state, :hibernate}
|
{:noreply, state, :hibernate}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -115,7 +123,7 @@ def handle_info({:DOWN, _ref, :process, pid, reason}, state) do
|
||||||
%{key: state.key}
|
%{key: state.key}
|
||||||
)
|
)
|
||||||
|
|
||||||
handle_cast({:remove_client, pid, false}, state)
|
handle_cast({:remove_client, pid}, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
# LRFU policy: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.1478
|
# LRFU policy: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.1478
|
||||||
|
|
Loading…
Reference in a new issue