Skip to content
Commit bf23d9a6 authored by Matt Whitlock's avatar Matt Whitlock Committed by Andrius Štikonas
Browse files

dht/KBucket: don't accumulate duplicate replacement entries

KBucket::pingQuestionable(const KBucketEntry &) stashes its argument (the
prospective replacement KBucketEntry) in the KBucket::pending_entries
QList if the number of outstanding pings of questionable entries is 2 or
more. Unfortunately, the function was not checking for duplicate entries
in the pending_entries list, which was causing unbounded memory usage as
duplicate replacement entries would rapidly accumulate in the list.

This commit modifies the pingQuestionable function so that, before
inserting a replacement entry into the pending_entries list, it first
removes any matching entry from that list. Then, it *prepends* the new
entry to the list (rather than appending as it did before this commit)
since we want to consider the *freshest* replacements first when
endeavoring to replace bad entries. To bound memory usage, the list of
pending replacements is constrained to contain no more than K entries.
parent 9192610d
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment