Skip to content

Commit

Permalink
skip failed and expiring tunnels for peer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Feb 15, 2024
1 parent d8be5b8 commit def404b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions libi2pd/TunnelPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,36 +364,24 @@ namespace tunnel
{
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
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::vector<std::shared_ptr<InboundTunnel> > inboundTunnels;
{
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
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);
auto it1 = outboundTunnels.begin ();
auto it2 = inboundTunnels.begin ();
while (it1 != outboundTunnels.end () && it2 != inboundTunnels.end ())
{
bool failed = false;
if ((*it1)->IsFailed ())
{
failed = true;
++it1;
}
if ((*it2)->IsFailed ())
{
failed = true;
++it2;
}
if (!failed)
{
newTests.push_back(std::make_pair (*it1, *it2));
++it1; ++it2;
}
newTests.push_back(std::make_pair (*it1, *it2));
++it1; ++it2;
}
for (auto& it: newTests)
{
Expand Down

0 comments on commit def404b

Please sign in to comment.