coalesce drop notifications

This commit is contained in:
Alain Zscheile 2022-11-27 21:52:41 +01:00
parent 30daf44281
commit 355d559195

View file

@ -94,6 +94,11 @@ defmodule Floof do
{backlog, sesskey}
{:fwddrop, dcdhash} ->
to_drop = coalesce_fwddrops(MapSet.new(dcdhash))
:ok = send_summary(client, :drop, to_drop)
{backlog, sesskey}
{:SessionPushed, sesskey} ->
sesskeys = coalesce_sesspushes([sesskey])
[sesskey | _] = sesskeys
@ -180,9 +185,9 @@ defmodule Floof do
{:xfer, xf} ->
mhash = Floof.Message.emit(xf)
# notify the remote end that we successfully consumed the message
# non-fatal if this fails
send_summary(client, :drop, [mhash])
# the following indirection is necessary
# to reduce the amount of 'drop' notifications
send(self(), {:fwddrop, mhash})
{backlog, sesskey}
end
end
@ -210,6 +215,14 @@ defmodule Floof do
end
end
defp coalesce_fwddrops(to_drop) do
receive do
{:fwddrop, dcdhash} -> coalesce_fwddrops(MapSet.put(to_drop, dcdhash))
after
10 -> to_drop
end
end
defp partition_hashes(xs) do
xs
|> Floof.DistributorSeen.have_we_multi()