Skip to content

Commit

Permalink
search: avoid removing node being added
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Béraud committed Dec 7, 2023
1 parent 111bfea commit 7ec70bd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@ Dht::Search::insertNode(const Sp<Node>& snode, time_point now, const Blob& token
}

while (nodes.size() - bad > SEARCH_NODES) {
bool removingNode = nodes.back()->node == snode;
if (removingNode)
break;
if (not expired and nodes.back()->isBad())
bad--;
nodes.pop_back();
Expand Down

0 comments on commit 7ec70bd

Please sign in to comment.