From d08b1576990ca33ac4178fb757ec03a777c55b5b Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 6 May 2020 21:51:10 +0300 Subject: [PATCH] Connection pool: check that there actually is a result Sometimes connections died before being released to the pool, resulting in MatchErrors --- lib/pleroma/gun/connection_pool.ex | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/gun/connection_pool.ex b/lib/pleroma/gun/connection_pool.ex index ed7ddff81..0daf1da44 100644 --- a/lib/pleroma/gun/connection_pool.ex +++ b/lib/pleroma/gun/connection_pool.ex @@ -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 -- 2.45.2