resubmit non-confirmed LeaseSet

This commit is contained in:
orignal 2016-10-24 20:58:25 -04:00
parent 4ee9b4524d
commit c74db4b81c
2 changed files with 18 additions and 25 deletions

View file

@ -106,6 +106,7 @@ namespace garlic
}; };
bool IsLeaseSetNonConfirmed () const { return m_LeaseSetUpdateStatus == eLeaseSetSubmitted; }; bool IsLeaseSetNonConfirmed () const { return m_LeaseSetUpdateStatus == eLeaseSetSubmitted; };
bool IsLeaseSetUpdated () const { return m_LeaseSetUpdateStatus == eLeaseSetUpdated; }; bool IsLeaseSetUpdated () const { return m_LeaseSetUpdateStatus == eLeaseSetUpdated; };
uint64_t GetLeaseSetSubmissionTime () const { return m_LeaseSetSubmissionTime; }
std::shared_ptr<GarlicRoutingPath> GetSharedRoutingPath (); std::shared_ptr<GarlicRoutingPath> GetSharedRoutingPath ();
void SetSharedRoutingPath (std::shared_ptr<GarlicRoutingPath> path); void SetSharedRoutingPath (std::shared_ptr<GarlicRoutingPath> path);

View file

@ -661,33 +661,25 @@ namespace stream
void Stream::SendUpdatedLeaseSet () void Stream::SendUpdatedLeaseSet ()
{ {
if (m_RoutingSession && m_RemoteLeaseSet && if (m_RoutingSession)
(m_RoutingSession->IsLeaseSetUpdated () || m_RoutingSession->IsLeaseSetNonConfirmed ()))
{ {
auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (true); // with threshold if (m_RoutingSession->IsLeaseSetNonConfirmed ())
if (!leases.empty ())
{ {
auto outboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (); auto ts = i2p::util::GetMillisecondsSinceEpoch ();
if (outboundTunnel) if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASET_CONFIRMATION_TIMEOUT)
{ {
auto lease = leases[rand () % leases.size ()]; // LeaseSet was not confirmed, should try other tunnels
auto msg = m_RoutingSession->WrapSingleMessage (nullptr); LogPrint (eLogWarning, "Streaming: LeaseSet was not confrimed in ", i2p::garlic::LEASET_CONFIRMATION_TIMEOUT, " milliseconds. Trying to resubmit");
outboundTunnel->SendTunnelDataMsg ( m_RoutingSession->SetSharedRoutingPath (nullptr);
{ m_CurrentOutboundTunnel = nullptr;
i2p::tunnel::TunnelMessageBlock m_CurrentRemoteLease = nullptr;
{ SendQuickAck ();
i2p::tunnel::eDeliveryTypeTunnel,
lease->tunnelGateway, lease->tunnelID,
msg
}
});
LogPrint (eLogDebug, "Streaming: Updated LeaseSet sent. sSID=", m_SendStreamID);
} }
} }
else else if (m_RoutingSession->IsLeaseSetUpdated ())
{ {
LogPrint (eLogWarning, "Streaming: Can't sent updated LeaseSet. Remote LeaseSet expired. sSID=", m_SendStreamID); LogPrint (eLogDebug, "Streaming: sending updated LeaseSet");
m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); SendQuickAck ();
} }
} }
} }