Connection pool: check that there actually is a result

Sometimes connections died before being released to the pool, resulting
in MatchErrors
This commit is contained in:
rinpatch 2020-05-06 21:51:10 +03:00
parent fffbcffb8c
commit d08b157699

View file

@ -119,11 +119,17 @@ defp get_gun_pid_from_worker(worker_pid) do
end end
def release_conn(conn_pid) do def release_conn(conn_pid) do
[worker_pid] = query_result =
Registry.select(@registry, [ Registry.select(@registry, [
{{:_, :"$1", {:"$2", :_, :_, :_}}, [{:==, :"$2", conn_pid}], [:"$1"]} {{:_, :"$1", {:"$2", :_, :_, :_}}, [{:==, :"$2", conn_pid}], [:"$1"]}
]) ])
GenServer.cast(worker_pid, {:remove_client, self()}) case query_result do
[worker_pid] ->
GenServer.cast(worker_pid, {:remove_client, self()})
[] ->
:ok
end
end end
end end