mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
use RouterInfo request callback instead timeout
This commit is contained in:
parent
ad9d7931f5
commit
e898e6bf82
|
@ -242,22 +242,22 @@ namespace transport
|
||||||
else // otherwise request RI
|
else // otherwise request RI
|
||||||
{
|
{
|
||||||
LogPrint ("Router not found. Requested");
|
LogPrint ("Router not found. Requested");
|
||||||
i2p::data::netdb.RequestDestination (ident);
|
i2p::data::netdb.RequestDestination (ident, std::bind (
|
||||||
auto resendTimer = new boost::asio::deadline_timer (m_Service);
|
&Transports::RequestComplete, this, std::placeholders::_1, ident));
|
||||||
resendTimer->expires_from_now (boost::posix_time::seconds(5)); // 5 seconds
|
|
||||||
resendTimer->async_wait (boost::bind (&Transports::HandleResendTimer,
|
|
||||||
this, boost::asio::placeholders::error, resendTimer, ident));
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::HandleResendTimer (const boost::system::error_code& ecode,
|
void Transports::RequestComplete (std::shared_ptr<const i2p::data::RouterInfo> r, const i2p::data::IdentHash& ident)
|
||||||
boost::asio::deadline_timer * timer, const i2p::data::IdentHash& ident)
|
{
|
||||||
|
m_Service.post (std::bind (&Transports::HandleRequestComplete, this, r, ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Transports::HandleRequestComplete (std::shared_ptr<const i2p::data::RouterInfo> r, const i2p::data::IdentHash& ident)
|
||||||
{
|
{
|
||||||
auto it = m_Peers.find (ident);
|
auto it = m_Peers.find (ident);
|
||||||
if (it != m_Peers.end ())
|
if (it != m_Peers.end ())
|
||||||
{
|
{
|
||||||
auto r = netdb.FindRouter (ident);
|
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
LogPrint ("Router found. Trying to connect");
|
LogPrint ("Router found. Trying to connect");
|
||||||
|
@ -270,7 +270,6 @@ namespace transport
|
||||||
m_Peers.erase (it);
|
m_Peers.erase (it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete timer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::CloseSession (std::shared_ptr<const i2p::data::RouterInfo> router)
|
void Transports::CloseSession (std::shared_ptr<const i2p::data::RouterInfo> router)
|
||||||
|
|
|
@ -88,8 +88,8 @@ namespace transport
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void Run ();
|
void Run ();
|
||||||
void HandleResendTimer (const boost::system::error_code& ecode, boost::asio::deadline_timer * timer,
|
void RequestComplete (std::shared_ptr<const i2p::data::RouterInfo> r, const i2p::data::IdentHash& ident);
|
||||||
const i2p::data::IdentHash& ident);
|
void HandleRequestComplete (std::shared_ptr<const i2p::data::RouterInfo> r, const i2p::data::IdentHash& ident);
|
||||||
void PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
|
void PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
|
||||||
void PostCloseSession (std::shared_ptr<const i2p::data::RouterInfo> router);
|
void PostCloseSession (std::shared_ptr<const i2p::data::RouterInfo> router);
|
||||||
bool ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer);
|
bool ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer);
|
||||||
|
|
Loading…
Reference in a new issue