Browse Source

cleanup I2NP msgs pool and routing sessions

pull/2094/head
orignal 4 months ago
parent
commit
8a3d6ddb3e
  1. 18
      libi2pd_client/I2CP.cpp
  2. 2
      libi2pd_client/I2CP.h

18
libi2pd_client/I2CP.cpp

@ -299,6 +299,12 @@ namespace client
return sent; return sent;
} }
void I2CPDestination::CleanupDestination ()
{
m_I2NPMsgsPool.CleanUpMt ();
if (m_Owner) m_Owner->CleanupRoutingSessions ();
}
RunnableI2CPDestination::RunnableI2CPDestination (std::shared_ptr<I2CPSession> owner, 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): std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params):
RunnableService ("I2CP"), RunnableService ("I2CP"),
@ -757,6 +763,18 @@ namespace client
m_RoutingSessions[signingKey] = remoteSession; 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) void I2CPSession::CreateLeaseSetMessageHandler (const uint8_t * buf, size_t len)
{ {
uint16_t sessionID = bufbe16toh (buf); uint16_t sessionID = bufbe16toh (buf);

2
libi2pd_client/I2CP.h

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

Loading…
Cancel
Save