mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
shared_ptr for RoutingDestination
This commit is contained in:
parent
938fa00469
commit
974a7ff3f5
7 changed files with 21 additions and 20 deletions
14
Garlic.cpp
14
Garlic.cpp
|
@ -15,7 +15,7 @@ namespace i2p
|
|||
namespace garlic
|
||||
{
|
||||
GarlicRoutingSession::GarlicRoutingSession (GarlicDestination * owner,
|
||||
const i2p::data::RoutingDestination * destination, int numTags):
|
||||
std::shared_ptr<const i2p::data::RoutingDestination> destination, int numTags):
|
||||
m_Owner (owner), m_Destination (destination), m_NumTags (numTags),
|
||||
m_LeaseSetUpdated (numTags > 0)
|
||||
{
|
||||
|
@ -501,7 +501,7 @@ namespace garlic
|
|||
}
|
||||
}
|
||||
|
||||
I2NPMessage * GarlicDestination::WrapMessage (const i2p::data::RoutingDestination& destination,
|
||||
I2NPMessage * GarlicDestination::WrapMessage (std::shared_ptr<const i2p::data::RoutingDestination> destination,
|
||||
I2NPMessage * msg, bool attachLeaseSet)
|
||||
{
|
||||
if (attachLeaseSet) // we should maintain this session
|
||||
|
@ -511,23 +511,23 @@ namespace garlic
|
|||
}
|
||||
else // one time session
|
||||
{
|
||||
GarlicRoutingSession session (this, &destination, 0); // don't use tag if no LeaseSet
|
||||
GarlicRoutingSession session (this, destination, 0); // don't use tag if no LeaseSet
|
||||
return session.WrapSingleMessage (msg);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GarlicRoutingSession> GarlicDestination::GetRoutingSession (
|
||||
const i2p::data::RoutingDestination& destination, int numTags)
|
||||
std::shared_ptr<const i2p::data::RoutingDestination> destination, int numTags)
|
||||
{
|
||||
auto it = m_Sessions.find (destination.GetIdentHash ());
|
||||
auto it = m_Sessions.find (destination->GetIdentHash ());
|
||||
std::shared_ptr<GarlicRoutingSession> session;
|
||||
if (it != m_Sessions.end ())
|
||||
session = it->second;
|
||||
if (!session)
|
||||
{
|
||||
session = std::make_shared<GarlicRoutingSession> (this, &destination, numTags);
|
||||
session = std::make_shared<GarlicRoutingSession> (this, destination, numTags);
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
m_Sessions[destination.GetIdentHash ()] = session;
|
||||
m_Sessions[destination->GetIdentHash ()] = session;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue