cleanup I2NP msgs pool and routing sessions

This commit is contained in:
orignal 2024-07-28 21:24:10 -04:00
parent 1410fa5c21
commit 8a3d6ddb3e
2 changed files with 20 additions and 0 deletions

View File

@ -298,6 +298,12 @@ namespace client
m_Owner->SendMessageStatusMessage (nonce, eI2CPMessageStatusGuaranteedSuccess);
return sent;
}
void I2CPDestination::CleanupDestination ()
{
m_I2NPMsgsPool.CleanUpMt ();
if (m_Owner) m_Owner->CleanupRoutingSessions ();
}
RunnableI2CPDestination::RunnableI2CPDestination (std::shared_ptr<I2CPSession> owner,
std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params):
@ -756,6 +762,18 @@ namespace client
std::lock_guard<std::mutex> l(m_RoutingSessionsMutex);
m_RoutingSessions[signingKey] = remoteSession;
}
void I2CPSession::CleanupRoutingSessions ()
{
std::lock_guard<std::mutex> l(m_RoutingSessionsMutex);
for (auto it = m_RoutingSessions.begin (); it != m_RoutingSessions.end ();)
{
if (it->second->IsTerminated ())
it = m_RoutingSessions.erase (it);
else
it++;
}
}
void I2CPSession::CreateLeaseSetMessageHandler (const uint8_t * buf, size_t len)
{

View File

@ -104,6 +104,7 @@ namespace client
protected:
void CleanupDestination ();
// I2CP
void HandleDataMessage (const uint8_t * buf, size_t len);
void CreateNewLeaseSet (const std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> >& tunnels);
@ -163,6 +164,7 @@ namespace client
void SendMessagePayloadMessage (const uint8_t * payload, size_t len);
void SendMessageStatusMessage (uint32_t nonce, I2CPMessageStatus status);
void AddRoutingSession (const i2p::data::IdentHash& signingKey, std::shared_ptr<i2p::garlic::GarlicRoutingSession> remoteSession);
void CleanupRoutingSessions ();
// message handlers
void GetDateMessageHandler (const uint8_t * buf, size_t len);