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 @@ defmodule Pleroma.Gun.ConnectionPool do
end
def release_conn(conn_pid) do
[worker_pid] =
query_result =
Registry.select(@registry, [
{{:_, :"$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