From ce7f592b1cc8eeb848e7fbd3a31ff0de68f8288d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Thu, 7 Dec 2023 15:08:11 -0500 Subject: [PATCH] search: return if added node is actually removed --- src/search.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/search.h b/src/search.h index ad7fc487f..99b6e3435 100644 --- a/src/search.h +++ b/src/search.h @@ -854,12 +854,17 @@ Dht::Search::insertNode(const Sp& 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;