aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/gun/connection_pool.ex
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-08-01 17:59:50 +0300
committerrinpatch <rinpatch@sdf.org>2020-08-01 18:02:26 +0300
commit45be1fe00e93fadab27a8e93e4537f11f6edd5eb (patch)
tree845d5caee4ad9cf1c4b9fa4d6066b17d4cfbd5a8 /lib/pleroma/gun/connection_pool.ex
parent3a6a4dd77aca3d423b92405e9cdbffca51b98bd3 (diff)
downloadpleroma-45be1fe00e93fadab27a8e93e4537f11f6edd5eb.tar.gz
ConnectionPool: fix gun open errors being returned without an error tuple
When gun shuts down due to the host being unreachable, the worker process shuts down with the same shutdown reason since they are linked. Gun doesn't have error tuples in it's shutdown reason though, so we need to handle it in get_conn. Closes #2008
Diffstat (limited to 'lib/pleroma/gun/connection_pool.ex')
-rw-r--r--lib/pleroma/gun/connection_pool.ex5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/pleroma/gun/connection_pool.ex b/lib/pleroma/gun/connection_pool.ex
index 49e9885bb..f34602b73 100644
--- a/lib/pleroma/gun/connection_pool.ex
+++ b/lib/pleroma/gun/connection_pool.ex
@@ -10,6 +10,7 @@ defmodule Pleroma.Gun.ConnectionPool do
]
end
+ @spec get_conn(URI.t(), keyword()) :: {:ok, pid()} | {:error, term()}
def get_conn(uri, opts) do
key = "#{uri.scheme}:#{uri.host}:#{uri.port}"
@@ -54,12 +55,14 @@ defmodule Pleroma.Gun.ConnectionPool do
{:DOWN, ^ref, :process, ^worker_pid, reason} ->
case reason do
- {:shutdown, error} -> error
+ {:shutdown, {:error, _} = error} -> error
+ {:shutdown, error} -> {:error, error}
_ -> {:error, reason}
end
end
end
+ @spec release_conn(pid()) :: :ok
def release_conn(conn_pid) do
# :ets.fun2ms(fn {_, {worker_pid, {gun_pid, _, _, _}}} when gun_pid == conn_pid ->
# worker_pid end)