From b0cf5130a24d4e1ca19073feaa72504a7791cfbb Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 3 May 2024 13:34:11 -0400 Subject: [PATCH] don't try another flloofill if request already exists --- libi2pd/NetDbRequests.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libi2pd/NetDbRequests.cpp b/libi2pd/NetDbRequests.cpp index 67b8d1ee..11a7a1e8 100644 --- a/libi2pd/NetDbRequests.cpp +++ b/libi2pd/NetDbRequests.cpp @@ -127,22 +127,20 @@ namespace data if (!ret.second) // not inserted { dest->SetRequestComplete (nullptr); // don't call requestComplete in destructor - if (requestComplete) + dest = ret.first->second; // existing one + if (requestComplete && dest->IsActive ()) { - auto prev = ret.first->second->GetRequestComplete (); + auto prev = dest->GetRequestComplete (); if (prev) // if already set - ret.first->second->SetRequestComplete ( + dest->SetRequestComplete ( [requestComplete, prev](std::shared_ptr r) { prev (r); // call previous requestComplete (r); // then new }); else - ret.first->second->SetRequestComplete (requestComplete); + dest->SetRequestComplete (requestComplete); } - if (i2p::util::GetSecondsSinceEpoch () > ret.first->second->GetLastRequestTime () + MIN_REQUEST_TIME) - if (!SendNextRequest (ret.first->second)) // try next floodfill - m_RequestedDestinations.erase (ret.first); // delete request if failed return nullptr; } } @@ -224,7 +222,7 @@ namespace data bool NetDbRequests::SendNextRequest (std::shared_ptr dest) { - if (!dest) return false; + if (!dest || !dest->IsActive ()) return false; bool ret = true; auto count = dest->GetNumExcludedPeers (); if (!dest->IsExploratory () && count < MAX_NUM_REQUEST_ATTEMPTS)