From 2208a06232d36d06e814d6f347d144ff866b379d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 9 Jan 2017 00:06:54 -0500 Subject: [PATCH] dht: clear acked with announce Clear the search node acked when clearing the corresponding announce, after checking the announce status for all announces. --- src/dht.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dht.cpp b/src/dht.cpp index 5c59a716..a7ccfdc4 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -685,7 +685,7 @@ struct Dht::Search { * @param now The time reference to now. */ void checkAnnounced(time_point now, Value::Id vid = Value::INVALID_ID) { - announce.erase(std::remove_if(announce.begin(), announce.end(), + auto announced = std::remove_if(announce.begin(), announce.end(), [this,&vid,&now](Announce& a) { if (vid != Value::INVALID_ID and (!a.value || a.value->id != vid)) return false; @@ -698,7 +698,13 @@ struct Dht::Search { return true; } return false; - }), announce.end()); + }); + // remove acked for cleared annouces + for (auto it = announced; it != announce.end(); ++it) { + for (auto& n : nodes) + n.acked.erase(it->value->id); + } + announce.erase(announced, announce.end()); } std::vector<std::shared_ptr<Node>> getNodes() const; -- GitLab