From c74db4b81c962563a51a6813bf7e8a4fe62097b8 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 24 Oct 2016 20:58:25 -0400 Subject: [PATCH] resubmit non-confirmed LeaseSet --- Garlic.h | 1 + Streaming.cpp | 42 +++++++++++++++++------------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Garlic.h b/Garlic.h index 0fa5403c..a3ab7d92 100644 --- a/Garlic.h +++ b/Garlic.h @@ -106,6 +106,7 @@ namespace garlic }; bool IsLeaseSetNonConfirmed () const { return m_LeaseSetUpdateStatus == eLeaseSetSubmitted; }; bool IsLeaseSetUpdated () const { return m_LeaseSetUpdateStatus == eLeaseSetUpdated; }; + uint64_t GetLeaseSetSubmissionTime () const { return m_LeaseSetSubmissionTime; } std::shared_ptr GetSharedRoutingPath (); void SetSharedRoutingPath (std::shared_ptr path); diff --git a/Streaming.cpp b/Streaming.cpp index 5eae1628..077adce4 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -661,33 +661,25 @@ namespace stream void Stream::SendUpdatedLeaseSet () { - if (m_RoutingSession && m_RemoteLeaseSet && - (m_RoutingSession->IsLeaseSetUpdated () || m_RoutingSession->IsLeaseSetNonConfirmed ())) - { - auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (true); // with threshold - if (!leases.empty ()) - { - auto outboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (); - if (outboundTunnel) - { - auto lease = leases[rand () % leases.size ()]; - auto msg = m_RoutingSession->WrapSingleMessage (nullptr); - outboundTunnel->SendTunnelDataMsg ( - { - i2p::tunnel::TunnelMessageBlock - { - i2p::tunnel::eDeliveryTypeTunnel, - lease->tunnelGateway, lease->tunnelID, - msg - } - }); - LogPrint (eLogDebug, "Streaming: Updated LeaseSet sent. sSID=", m_SendStreamID); + if (m_RoutingSession) + { + if (m_RoutingSession->IsLeaseSetNonConfirmed ()) + { + auto ts = i2p::util::GetMillisecondsSinceEpoch (); + if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASET_CONFIRMATION_TIMEOUT) + { + // LeaseSet was not confirmed, should try other tunnels + LogPrint (eLogWarning, "Streaming: LeaseSet was not confrimed in ", i2p::garlic::LEASET_CONFIRMATION_TIMEOUT, " milliseconds. Trying to resubmit"); + m_RoutingSession->SetSharedRoutingPath (nullptr); + m_CurrentOutboundTunnel = nullptr; + m_CurrentRemoteLease = nullptr; + SendQuickAck (); } - } - else + } + else if (m_RoutingSession->IsLeaseSetUpdated ()) { - LogPrint (eLogWarning, "Streaming: Can't sent updated LeaseSet. Remote LeaseSet expired. sSID=", m_SendStreamID); - m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); + LogPrint (eLogDebug, "Streaming: sending updated LeaseSet"); + SendQuickAck (); } } }