projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Connection pool: Fix race conditions in limit enforcement
[akkoma]
/
lib
/
pleroma
/
gun
/
connection_pool
/
worker.ex
diff --git
a/lib/pleroma/gun/connection_pool/worker.ex
b/lib/pleroma/gun/connection_pool/worker.ex
index ebde4bbf6f2bdacf44a21e9b310d6bb75c073662..25fafc64c3c4de58f9db4f28f2874292f1ab27fb 100644
(file)
--- a/
lib/pleroma/gun/connection_pool/worker.ex
+++ b/
lib/pleroma/gun/connection_pool/worker.ex
@@
-1,9
+1,13
@@
defmodule Pleroma.Gun.ConnectionPool.Worker do
alias Pleroma.Gun
defmodule Pleroma.Gun.ConnectionPool.Worker do
alias Pleroma.Gun
- use GenServer
+ use GenServer
, restart: :temporary
@registry Pleroma.Gun.ConnectionPool
@registry Pleroma.Gun.ConnectionPool
+ def start_link(opts) do
+ GenServer.start_link(__MODULE__, opts)
+ end
+
@impl true
def init([uri, key, opts, client_pid]) do
time = :os.system_time(:second)
@impl true
def init([uri, key, opts, client_pid]) do
time = :os.system_time(:second)
@@
-82,12
+86,6
@@
defmodule Pleroma.Gun.ConnectionPool.Worker do
{:stop, {:error, down_message}, state}
end
{:stop, {:error, down_message}, state}
end
- @impl true
- def handle_call(:idle_close, _, %{key: key} = state) do
- Registry.unregister(@registry, key)
- {:stop, :normal, state}
- end
-
# LRFU policy: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.1478
defp crf(time_delta, prev_crf) do
1 + :math.pow(0.5, time_delta / 100) * prev_crf
# LRFU policy: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.1478
defp crf(time_delta, prev_crf) do
1 + :math.pow(0.5, time_delta / 100) * prev_crf