aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-09-16 15:10:20 +0000
committerrinpatch <rinpatch@sdf.org>2020-09-16 15:10:20 +0000
commita4f80e1e741bc49d8d3eb185448a457308dda3ba (patch)
tree3dad88d02be86605810b0cb27bb3f9e1751c6f7e
parenteca8d267846afc802f9a5ceed036482a9c90b4e2 (diff)
parentadb1b0282dfbced2b2986c90cff765be37dd5151 (diff)
downloadpleroma-a4f80e1e741bc49d8d3eb185448a457308dda3ba.tar.gz
Merge branch 'feat/connection-worker-monitor-flush' into 'develop'
ConnectionPool Worker: use monitor flush instead of checking ref See merge request pleroma/pleroma!3002
-rw-r--r--lib/pleroma/gun/connection_pool/worker.ex23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/pleroma/gun/connection_pool/worker.ex b/lib/pleroma/gun/connection_pool/worker.ex
index 49d41e4c7..bf57e9e5f 100644
--- a/lib/pleroma/gun/connection_pool/worker.ex
+++ b/lib/pleroma/gun/connection_pool/worker.ex
@@ -93,25 +93,18 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
end)
{ref, state} = pop_in(state.client_monitors[client_pid])
- # DOWN message can receive right after `remove_client` call and cause worker to terminate
- state =
- if is_nil(ref) do
- state
- else
- Process.demonitor(ref)
- timer =
- if used_by == [] do
- max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
- Process.send_after(self(), :idle_close, max_idle)
- else
- nil
- end
+ Process.demonitor(ref, [:flush])
- %{state | timer: timer}
+ timer =
+ if used_by == [] do
+ max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
+ Process.send_after(self(), :idle_close, max_idle)
+ else
+ nil
end
- {:reply, :ok, state, :hibernate}
+ {:reply, :ok, %{state | timer: timer}, :hibernate}
end
@impl true