mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 09:04:14 +00:00
eliminate local destination mutex
This commit is contained in:
parent
67863cfcf9
commit
56ec8fe95b
@ -128,7 +128,6 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
m_InboundTunnels.insert (createdTunnel);
|
m_InboundTunnels.insert (createdTunnel);
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
if (m_LocalDestination)
|
if (m_LocalDestination)
|
||||||
m_LocalDestination->SetLeaseSetUpdated ();
|
m_LocalDestination->SetLeaseSetUpdated ();
|
||||||
}
|
}
|
||||||
@ -266,16 +265,6 @@ namespace tunnel
|
|||||||
return tunnel;
|
return tunnel;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<i2p::garlic::GarlicDestination> TunnelPool::GetLocalDestination () const {
|
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
return m_LocalDestination;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TunnelPool::SetLocalDestination (std::shared_ptr<i2p::garlic::GarlicDestination> destination) {
|
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
m_LocalDestination = destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TunnelPool::CreateTunnels ()
|
void TunnelPool::CreateTunnels ()
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -307,7 +296,6 @@ namespace tunnel
|
|||||||
for (int i = num; i < m_NumInboundTunnels; i++)
|
for (int i = num; i < m_NumInboundTunnels; i++)
|
||||||
CreateInboundTunnel ();
|
CreateInboundTunnel ();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
if (num < m_NumInboundTunnels && m_NumInboundHops <= 0 && m_LocalDestination) // zero hops IB
|
if (num < m_NumInboundTunnels && m_NumInboundHops <= 0 && m_LocalDestination) // zero hops IB
|
||||||
m_LocalDestination->SetLeaseSetUpdated (); // update LeaseSet immediately
|
m_LocalDestination->SetLeaseSetUpdated (); // update LeaseSet immediately
|
||||||
}
|
}
|
||||||
@ -344,7 +332,6 @@ namespace tunnel
|
|||||||
std::unique_lock<std::mutex> li(m_InboundTunnelsMutex);
|
std::unique_lock<std::mutex> li(m_InboundTunnelsMutex);
|
||||||
m_InboundTunnels.erase (it.second.second);
|
m_InboundTunnels.erase (it.second.second);
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> ld(m_LocalDestinationMutex);
|
|
||||||
if (m_LocalDestination)
|
if (m_LocalDestination)
|
||||||
m_LocalDestination->SetLeaseSetUpdated ();
|
m_LocalDestination->SetLeaseSetUpdated ();
|
||||||
}
|
}
|
||||||
@ -398,7 +385,6 @@ namespace tunnel
|
|||||||
|
|
||||||
void TunnelPool::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg)
|
void TunnelPool::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
if (m_LocalDestination)
|
if (m_LocalDestination)
|
||||||
m_LocalDestination->ProcessGarlicMessage (msg);
|
m_LocalDestination->ProcessGarlicMessage (msg);
|
||||||
else
|
else
|
||||||
@ -447,7 +433,6 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_LocalDestinationMutex);
|
|
||||||
if (m_LocalDestination)
|
if (m_LocalDestination)
|
||||||
m_LocalDestination->ProcessDeliveryStatusMessage (msg);
|
m_LocalDestination->ProcessDeliveryStatusMessage (msg);
|
||||||
else
|
else
|
||||||
@ -636,10 +621,8 @@ namespace tunnel
|
|||||||
Path path;
|
Path path;
|
||||||
if (SelectPeers (path, false))
|
if (SelectPeers (path, false))
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> ld(m_LocalDestinationMutex);
|
|
||||||
if (m_LocalDestination && !m_LocalDestination->SupportsEncryptionType (i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD))
|
if (m_LocalDestination && !m_LocalDestination->SupportsEncryptionType (i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD))
|
||||||
path.isShort = false; // because can't handle ECIES encrypted reply
|
path.isShort = false; // because can't handle ECIES encrypted reply
|
||||||
ld.unlock();
|
|
||||||
|
|
||||||
std::shared_ptr<TunnelConfig> config;
|
std::shared_ptr<TunnelConfig> config;
|
||||||
if (m_NumOutboundHops > 0)
|
if (m_NumOutboundHops > 0)
|
||||||
|
@ -64,8 +64,8 @@ namespace tunnel
|
|||||||
TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels);
|
TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels);
|
||||||
~TunnelPool ();
|
~TunnelPool ();
|
||||||
|
|
||||||
std::shared_ptr<i2p::garlic::GarlicDestination> GetLocalDestination () const;
|
std::shared_ptr<i2p::garlic::GarlicDestination> GetLocalDestination () const { return m_LocalDestination; };
|
||||||
void SetLocalDestination (std::shared_ptr<i2p::garlic::GarlicDestination> destination);
|
void SetLocalDestination (std::shared_ptr<i2p::garlic::GarlicDestination> destination) { m_LocalDestination = destination; };
|
||||||
void SetExplicitPeers (std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers);
|
void SetExplicitPeers (std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers);
|
||||||
|
|
||||||
void CreateTunnels ();
|
void CreateTunnels ();
|
||||||
@ -126,7 +126,6 @@ namespace tunnel
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
mutable std::mutex m_LocalDestinationMutex;
|
|
||||||
std::shared_ptr<i2p::garlic::GarlicDestination> m_LocalDestination;
|
std::shared_ptr<i2p::garlic::GarlicDestination> m_LocalDestination;
|
||||||
int m_NumInboundHops, m_NumOutboundHops, m_NumInboundTunnels, m_NumOutboundTunnels;
|
int m_NumInboundHops, m_NumOutboundHops, m_NumInboundTunnels, m_NumOutboundTunnels;
|
||||||
mutable std::mutex m_ExplicitPeersMutex;
|
mutable std::mutex m_ExplicitPeersMutex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user