From 6042aefd17e973448ac8f3d47df8736279af33b0 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 21 Nov 2014 13:02:46 -0500 Subject: [PATCH] delete dead floodfill --- HTTPServer.cpp | 4 ++-- NetDb.cpp | 7 +++++++ NetDb.h | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index ca341179..e5f74184 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -710,7 +710,7 @@ namespace util if (it.second && it.second->IsEstablished ()) { // incoming connection doesn't have remote RI - bool outgoing = it.second->GetRemoteRouter (); + auto outgoing = it.second->GetRemoteRouter (); if (outgoing) s << "-->"; s << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase64 ().substr (0, 4) << ": " << it.second->GetSocket ().remote_endpoint().address ().to_string (); @@ -727,7 +727,7 @@ namespace util for (auto it: ssuServer->GetSessions ()) { // incoming connections don't have remote router - bool outgoing = it.second->GetRemoteRouter (); + auto outgoing = it.second->GetRemoteRouter (); auto endpoint = it.second->GetRemoteEndpoint (); if (outgoing) s << "-->"; s << endpoint.address ().to_string () << ":" << endpoint.port (); diff --git a/NetDb.cpp b/NetDb.cpp index aeb3ffde..58c7f280 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -354,11 +354,18 @@ namespace data if (it.second->IsUnreachable ()) { + // delete RI file if (boost::filesystem::exists (GetFilePath (fullDirectory, it.second.get ()))) { boost::filesystem::remove (GetFilePath (fullDirectory, it.second.get ())); deletedCount++; } + // delete from floodfills list + if (it.second->IsFloodfill ()) + { + std::unique_lock l(m_FloodfillsMutex); + m_Floodfills.remove (it.second); + } } } } diff --git a/NetDb.h b/NetDb.h index 914ca9e7..996c973f 100644 --- a/NetDb.h +++ b/NetDb.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -111,7 +111,7 @@ namespace data std::map m_LeaseSets; std::map > m_RouterInfos; mutable std::mutex m_FloodfillsMutex; - std::vector > m_Floodfills; + std::list > m_Floodfills; std::mutex m_RequestedDestinationsMutex; std::map m_RequestedDestinations;