Browse Source

fixed datagram idle crash

pull/1542/head
orignal 4 years ago
parent
commit
31494267e5
  1. 12
      libi2pd/Datagram.cpp

12
libi2pd/Datagram.cpp

@ -318,8 +318,12 @@ namespace datagram
if (path) if (path)
{ {
if (path->outboundTunnel && !path->outboundTunnel->IsEstablished ()) if (path->outboundTunnel && !path->outboundTunnel->IsEstablished ())
{
// bad outbound tunnel, switch outbound tunnel // bad outbound tunnel, switch outbound tunnel
path->outboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel(path->outboundTunnel); path->outboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel(path->outboundTunnel);
if (!path->outboundTunnel)
m_RoutingSession->SetSharedRoutingPath (nullptr);
}
if (path->remoteLease && path->remoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW)) if (path->remoteLease && path->remoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW))
{ {
@ -338,11 +342,14 @@ namespace datagram
path->remoteLease = ls[idx]; path->remoteLease = ls[idx];
} }
else else
path->remoteLease = nullptr; m_RoutingSession->SetSharedRoutingPath (nullptr);
} }
else else
{
// no remote lease set? // no remote lease set?
LogPrint(eLogWarning, "DatagramSession: no cached remote lease set for ", m_RemoteIdent.ToBase32()); LogPrint(eLogWarning, "DatagramSession: no cached remote lease set for ", m_RemoteIdent.ToBase32());
m_RoutingSession->SetSharedRoutingPath (nullptr);
}
} }
} }
else else
@ -350,6 +357,7 @@ namespace datagram
// no current path, make one // no current path, make one
path = std::make_shared<i2p::garlic::GarlicRoutingPath>(); path = std::make_shared<i2p::garlic::GarlicRoutingPath>();
path->outboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel(); path->outboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel();
if (!path->outboundTunnel) return nullptr;
if (m_RemoteLeaseSet) if (m_RemoteLeaseSet)
{ {
@ -361,6 +369,8 @@ namespace datagram
auto idx = rand() % sz; auto idx = rand() % sz;
path->remoteLease = ls[idx]; path->remoteLease = ls[idx];
} }
else
return nullptr;
} }
else else
{ {

Loading…
Cancel
Save