ConnectionPool.Worker: do not stop with an error when there is a timeout
authorrinpatch <rinpatch@sdf.org>
Wed, 15 Jul 2020 12:58:08 +0000 (15:58 +0300)
committerrinpatch <rinpatch@sdf.org>
Wed, 15 Jul 2020 12:58:08 +0000 (15:58 +0300)
This produced error log messages about GenServer termination
every time the connection was not open due to a timeout.

Instead we stop with `{:shutdown, <gun_error>}` since shutting down
when the connection can't be established is normal behavior.

lib/pleroma/gun/connection_pool.ex
lib/pleroma/gun/connection_pool/worker.ex

index d3eead7d8be841b0dc15e9640404b022bdfe1f92..8b41a668c0268c504ec55ddc05bbb7545aedcffe 100644 (file)
@@ -53,7 +53,10 @@ defmodule Pleroma.Gun.ConnectionPool do
         {:ok, pid}
 
       {:DOWN, ^ref, :process, ^worker_pid, reason} ->
-        {:error, reason}
+        case reason do
+          {:shutdown, error} -> error
+          _ -> {:error, reason}
+        end
     end
   end
 
index 16a508ad96b32277e3834ddec46a0ec7092a4769..f33447cb6352c137f88e2b15757c1145bd9445b0 100644 (file)
@@ -31,7 +31,7 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
        :hibernate}
     else
       err ->
-        {:stop, err, nil}
+        {:stop, {:shutdown, err}, nil}
     end
   end