1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 12:24:19 +00:00

delay request

This commit is contained in:
Jeff Becker 2017-04-08 14:15:08 -04:00
parent 9b62f238ed
commit 89dfe2b763
2 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,7 @@ namespace client
: ClientDestination(keys, false, params), : ClientDestination(keys, false, params),
m_RemoteName(remoteName) {} m_RemoteName(remoteName) {}
void MatchedTunnelDestination::ResolveCurrentLeaseSet() void MatchedTunnelDestination::ResolveCurrentLeaseSet()
{ {
if(i2p::client::context.GetAddressBook().GetIdentHash(m_RemoteName, m_RemoteIdent)) if(i2p::client::context.GetAddressBook().GetIdentHash(m_RemoteName, m_RemoteIdent))
@ -35,7 +36,12 @@ namespace client
m_RemoteLeaseSet = ls; m_RemoteLeaseSet = ls;
} }
else else
ResolveCurrentLeaseSet(); {
m_ResolveTimer->expires_from_now(boost::posix_time::seconds(1));
m_ResolveTimer->async_wait([&](const boost::system::error_code & ec) {
if(!ec) ResolveCurrentLeaseSet();
});
}
} }
@ -43,6 +49,7 @@ namespace client
{ {
if(ClientDestination::Start()) if(ClientDestination::Start())
{ {
m_ResolveTimer = std::make_shared<boost::asio::deadline_timer>(GetService());
GetTunnelPool()->SetCustomPeerSelector(this); GetTunnelPool()->SetCustomPeerSelector(this);
ResolveCurrentLeaseSet(); ResolveCurrentLeaseSet();
return true; return true;
@ -55,7 +62,8 @@ namespace client
{ {
if(ClientDestination::Stop()) if(ClientDestination::Stop())
{ {
if(m_ResolveTimer)
m_ResolveTimer->cancel();
return true; return true;
} }
else else

View File

@ -28,6 +28,7 @@ namespace client
std::string m_RemoteName; std::string m_RemoteName;
i2p::data::IdentHash m_RemoteIdent; i2p::data::IdentHash m_RemoteIdent;
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet; std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
std::shared_ptr<boost::asio::deadline_timer> m_ResolveTimer;
}; };
} }
} }