mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
skip failed and expiring tunnels for peer tests
This commit is contained in:
parent
d8be5b8ce1
commit
def404b61a
|
@ -364,36 +364,24 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
||||||
for (auto& it: m_OutboundTunnels)
|
for (auto& it: m_OutboundTunnels)
|
||||||
outboundTunnels.push_back (it);
|
if (it->IsEstablished () || it->GetState () == eTunnelStateTestFailed)
|
||||||
|
outboundTunnels.push_back (it);
|
||||||
}
|
}
|
||||||
std::shuffle (outboundTunnels.begin(), outboundTunnels.end(), m_Rng);
|
std::shuffle (outboundTunnels.begin(), outboundTunnels.end(), m_Rng);
|
||||||
std::vector<std::shared_ptr<InboundTunnel> > inboundTunnels;
|
std::vector<std::shared_ptr<InboundTunnel> > inboundTunnels;
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
||||||
for (auto& it: m_InboundTunnels)
|
for (auto& it: m_InboundTunnels)
|
||||||
inboundTunnels.push_back (it);
|
if (it->IsEstablished () || it->GetState () == eTunnelStateTestFailed)
|
||||||
|
inboundTunnels.push_back (it);
|
||||||
}
|
}
|
||||||
std::shuffle (inboundTunnels.begin(), inboundTunnels.end(), m_Rng);
|
std::shuffle (inboundTunnels.begin(), inboundTunnels.end(), m_Rng);
|
||||||
auto it1 = outboundTunnels.begin ();
|
auto it1 = outboundTunnels.begin ();
|
||||||
auto it2 = inboundTunnels.begin ();
|
auto it2 = inboundTunnels.begin ();
|
||||||
while (it1 != outboundTunnels.end () && it2 != inboundTunnels.end ())
|
while (it1 != outboundTunnels.end () && it2 != inboundTunnels.end ())
|
||||||
{
|
{
|
||||||
bool failed = false;
|
newTests.push_back(std::make_pair (*it1, *it2));
|
||||||
if ((*it1)->IsFailed ())
|
++it1; ++it2;
|
||||||
{
|
|
||||||
failed = true;
|
|
||||||
++it1;
|
|
||||||
}
|
|
||||||
if ((*it2)->IsFailed ())
|
|
||||||
{
|
|
||||||
failed = true;
|
|
||||||
++it2;
|
|
||||||
}
|
|
||||||
if (!failed)
|
|
||||||
{
|
|
||||||
newTests.push_back(std::make_pair (*it1, *it2));
|
|
||||||
++it1; ++it2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (auto& it: newTests)
|
for (auto& it: newTests)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue