gun ConnectionPool: Re-add a missing cast for remove_client
authorrinpatch <rinpatch@sdf.org>
Tue, 28 Jul 2020 20:48:41 +0000 (23:48 +0300)
committerrinpatch <rinpatch@sdf.org>
Tue, 28 Jul 2020 20:48:41 +0000 (23:48 +0300)
lib/pleroma/gun/connection_pool.ex
lib/pleroma/gun/connection_pool/worker.ex

index c6894be53dd9e75f23ed43ac4275e9281bace05a..49e9885bbac3b82d224c901c458a7c41d5225901 100644 (file)
@@ -45,7 +45,7 @@ defmodule Pleroma.Gun.ConnectionPool do
     # so instead we use cast + monitor
 
     ref = Process.monitor(worker_pid)
-    if register, do: GenServer.cast(worker_pid, {:add_client, self(), true})
+    if register, do: GenServer.cast(worker_pid, {:add_client, self()})
 
     receive do
       {:conn_pid, pid} ->
index a61892c60aa384ecc89a0d5247506e72eb38b81e..fec9d0efa9daa0323a02e26159c491e00313424d 100644 (file)
@@ -36,10 +36,18 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
   end
 
   @impl true
-  def handle_cast({:add_client, client_pid, send}, state) do
+  def handle_cast({:add_client, client_pid}, state) do
     case handle_call(:add_client, {client_pid, nil}, state) do
       {:reply, conn_pid, state, :hibernate} ->
-        if send, do: send(client_pid, {:conn_pid, conn_pid})
+        send(client_pid, {:conn_pid, conn_pid})
+        {:noreply, state, :hibernate}
+    end
+  end
+
+  @impl true
+  def handle_cast({:remove_client, client_pid}, state) do
+    case handle_call(:remove_client, {client_pid, nil}, state) do
+      {:reply, _, state, :hibernate} ->
         {:noreply, state, :hibernate}
     end
   end
@@ -115,7 +123,7 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
       %{key: state.key}
     )
 
-    handle_cast({:remove_client, pid, false}, state)
+    handle_cast({:remove_client, pid}, state)
   end
 
   # LRFU policy: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.1478