From fdd96975fb573e7fc259e2e51ffd5b333fb0c421 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 13 Dec 2015 14:40:43 -0500 Subject: [PATCH] cancel destination request --- AddressBook.cpp | 3 +++ Destination.cpp | 11 +++++++++++ Destination.h | 1 + 3 files changed, 15 insertions(+) diff --git a/AddressBook.cpp b/AddressBook.cpp index f98371f3..49551f10 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -495,7 +495,10 @@ namespace client newDataReceived.notify_all (); }); if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT)) == std::cv_status::timeout) + { LogPrint (eLogError, "Subscription LeseseSet request timeout expired"); + i2p::client::context.GetSharedLocalDestination ()->CancelDestinationRequest (ident); + } } if (leaseSet) { diff --git a/Destination.cpp b/Destination.cpp index 826af4ef..9c5bb700 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -533,6 +533,17 @@ namespace client return true; } + void ClientDestination::CancelDestinationRequest (const i2p::data::IdentHash& dest) + { + auto s = shared_from_this (); + m_Service.post ([dest, s](void) + { + auto it = s->m_LeaseSetRequests.find (dest); + if (it != s->m_LeaseSetRequests.end ()) + s->m_LeaseSetRequests.erase (it); + }); + } + void ClientDestination::RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete) { std::set excluded; diff --git a/Destination.h b/Destination.h index aa7123e7..d38fe30e 100644 --- a/Destination.h +++ b/Destination.h @@ -73,6 +73,7 @@ namespace client bool IsReady () const { return m_LeaseSet && m_LeaseSet->HasNonExpiredLeases () && m_Pool->GetOutboundTunnels ().size () > 0; }; std::shared_ptr FindLeaseSet (const i2p::data::IdentHash& ident); bool RequestDestination (const i2p::data::IdentHash& dest, RequestComplete requestComplete = nullptr); + void CancelDestinationRequest (const i2p::data::IdentHash& dest); // streaming std::shared_ptr CreateStreamingDestination (int port); // additional