소스 검색

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
issue/1969
rinpatch 3 년 전
부모
커밋
45be1fe00e
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. +4
    -1
      lib/pleroma/gun/connection_pool.ex

+ 4
- 1
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)


불러오는 중...
취소
저장