|
|
@ -256,7 +256,7 @@ namespace tunnel |
|
|
|
size_t minReceived = 0; |
|
|
|
size_t minReceived = 0; |
|
|
|
for (auto it : m_InboundTunnels) |
|
|
|
for (auto it : m_InboundTunnels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (it.second->IsFailed ()) continue; |
|
|
|
if (!it.second->IsEstablished ()) continue; |
|
|
|
if (!tunnel || it.second->GetNumReceivedBytes () < minReceived) |
|
|
|
if (!tunnel || it.second->GetNumReceivedBytes () < minReceived) |
|
|
|
{ |
|
|
|
{ |
|
|
|
tunnel = it.second; |
|
|
|
tunnel = it.second; |
|
|
@ -274,7 +274,7 @@ namespace tunnel |
|
|
|
for (auto it: m_OutboundTunnels) |
|
|
|
for (auto it: m_OutboundTunnels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (i >= ind) return it; |
|
|
|
if (i >= ind) return it; |
|
|
|
if (!it->IsFailed ()) |
|
|
|
if (it->IsEstablished ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
tunnel = it; |
|
|
|
tunnel = it; |
|
|
|
i++; |
|
|
|
i++; |
|
|
@ -408,8 +408,12 @@ namespace tunnel |
|
|
|
it = m_OutboundTunnels.erase (it); |
|
|
|
it = m_OutboundTunnels.erase (it); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ts + TUNNEL_EXPIRATION_THRESHOLD > (*it)->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
|
|
|
|
|
(*it)->SetState (eTunnelStateExpiring); |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_OutboundTunnels.size () < 5) |
|
|
|
if (m_OutboundTunnels.size () < 5) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -441,8 +445,12 @@ namespace tunnel |
|
|
|
it = m_InboundTunnels.erase (it); |
|
|
|
it = m_InboundTunnels.erase (it); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ts + TUNNEL_EXPIRATION_THRESHOLD > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
|
|
|
|
|
it->second->SetState (eTunnelStateExpiring); |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_InboundTunnels.empty ()) |
|
|
|
if (m_InboundTunnels.empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|