Browse Source

don't update expired tunnels

pull/1553/merge
orignal 4 years ago
parent
commit
3925540517
  1. 17
      libi2pd/TunnelPool.cpp

17
libi2pd/TunnelPool.cpp

@ -292,8 +292,6 @@ namespace tunnel
} }
// new tests // new tests
std::unique_lock<std::mutex> l1(m_OutboundTunnelsMutex);
std::unique_lock<std::mutex> l2(m_InboundTunnelsMutex);
auto it1 = m_OutboundTunnels.begin (); auto it1 = m_OutboundTunnels.begin ();
auto it2 = m_InboundTunnels.begin (); auto it2 = m_InboundTunnels.begin ();
while (it1 != m_OutboundTunnels.end () && it2 != m_InboundTunnels.end ()) while (it1 != m_OutboundTunnels.end () && it2 != m_InboundTunnels.end ())
@ -363,18 +361,25 @@ namespace tunnel
} }
if (found) if (found)
{ {
uint64_t dlt = i2p::util::GetMillisecondsSinceEpoch () - timestamp;
LogPrint (eLogDebug, "Tunnels: test of ", msgID, " successful. ", dlt, " milliseconds");
uint64_t latency = dlt / 2;
// restore from test failed state if any // restore from test failed state if any
if (test.first)
{
if (test.first->GetState () == eTunnelStateTestFailed) if (test.first->GetState () == eTunnelStateTestFailed)
test.first->SetState (eTunnelStateEstablished); test.first->SetState (eTunnelStateEstablished);
// update latency
test.first->AddLatencySample(latency);
}
if (test.second)
{
if (test.second->GetState () == eTunnelStateTestFailed) if (test.second->GetState () == eTunnelStateTestFailed)
test.second->SetState (eTunnelStateEstablished); test.second->SetState (eTunnelStateEstablished);
uint64_t dlt = i2p::util::GetMillisecondsSinceEpoch () - timestamp;
LogPrint (eLogDebug, "Tunnels: test of ", msgID, " successful. ", dlt, " milliseconds");
// update latency // update latency
uint64_t latency = dlt / 2;
test.first->AddLatencySample(latency);
test.second->AddLatencySample(latency); test.second->AddLatencySample(latency);
} }
}
else else
{ {
if (m_LocalDestination) if (m_LocalDestination)

Loading…
Cancel
Save