Skip to content

Commit

Permalink
search: return if added node is actually removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Béraud authored and aberaud committed Dec 8, 2023
1 parent 111bfea commit ce7f592
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,17 @@ Dht::Search::insertNode(const Sp<Node>& snode, time_point now, const Blob& token
expired = false;
}

while (nodes.size() - bad > SEARCH_NODES) {
while (nodes.size() - bad > SEARCH_NODES) {
bool removingNode = nodes.back()->node == snode;
if (not expired and nodes.back()->isBad())
bad--;
nodes.pop_back();
if (removingNode)
return false;
}
}
if (n == nodes.end() or not *n)
return false;
if (not token.empty()) {
(*n)->candidate = false;
(*n)->last_get_reply = now;
Expand Down

0 comments on commit ce7f592

Please sign in to comment.