another try at fixing timeout issues
This commit is contained in:
parent
63ac6567b6
commit
b10928e533
|
@ -18,23 +18,23 @@ defmodule Floof.PacketSpool do
|
|||
|
||||
## packet is expected to be of type :XferBlob
|
||||
def store(hash, packet) do
|
||||
GenServer.call(__MODULE__, {:store, hash, packet, true}, 10000)
|
||||
GenServer.call(__MODULE__, {:store, hash, packet, true})
|
||||
end
|
||||
|
||||
def store_multi(packets) do
|
||||
GenServer.call(__MODULE__, {:store, packets, true}, 10000)
|
||||
GenServer.call(__MODULE__, {:store, packets, true})
|
||||
end
|
||||
|
||||
def store_new(hash, packet) do
|
||||
GenServer.call(__MODULE__, {:store, hash, packet, false}, 10000)
|
||||
GenServer.call(__MODULE__, {:store, hash, packet, false})
|
||||
end
|
||||
|
||||
def store_new_multi(packets) do
|
||||
GenServer.call(__MODULE__, {:store, packets, false}, 10000)
|
||||
GenServer.call(__MODULE__, {:store, packets, false})
|
||||
end
|
||||
|
||||
def fetch(hash) do
|
||||
GenServer.call(__MODULE__, {:fetch, hash}, 10000)
|
||||
GenServer.call(__MODULE__, {:fetch, hash})
|
||||
end
|
||||
|
||||
def drop(hash) do
|
||||
|
@ -130,7 +130,7 @@ defmodule Floof.PacketSpool do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_call({:collect_garbage_keep_only, to_keep}, _, state) do
|
||||
def handle_cast({:collect_garbage_keep_only, to_keep}, state) do
|
||||
{:ok, items} = File.ls(state)
|
||||
|
||||
present =
|
||||
|
@ -164,6 +164,9 @@ defmodule Floof.PacketSpool do
|
|||
end
|
||||
end
|
||||
|
||||
# this might seem counter-intuitively, but it prevents unnecessary timeouts
|
||||
Process.send_after(Floof.SessionManager, :collect_garbage, 15 * 1000)
|
||||
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ defmodule Floof.SessionManager do
|
|||
end
|
||||
|
||||
def peek(key) do
|
||||
GenServer.call(__MODULE__, {:peek, key}, 10000)
|
||||
GenServer.call(__MODULE__, {:peek, key}, :infinity)
|
||||
end
|
||||
|
||||
def drop(key, subkeys) do
|
||||
|
@ -154,8 +154,7 @@ defmodule Floof.SessionManager do
|
|||
|
||||
keys ->
|
||||
to_keep = Enum.map(keys, fn [x] -> x end)
|
||||
GenServer.call(Floof.PacketSpool, {:collect_garbage_keep_only, to_keep}, 10000)
|
||||
Process.send_after(self(), :collect_garbage, 15 * 1000)
|
||||
GenServer.cast(Floof.PacketSpool, {:collect_garbage_keep_only, to_keep})
|
||||
end
|
||||
|
||||
{:noreply, state}
|
||||
|
|
Loading…
Reference in a new issue