mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
queue up multiple LeaseSet requests
This commit is contained in:
parent
913438e3ff
commit
1dfa09cda9
@ -86,7 +86,7 @@ namespace client
|
|||||||
if (m_IsRunning)
|
if (m_IsRunning)
|
||||||
Stop ();
|
Stop ();
|
||||||
for (auto& it: m_LeaseSetRequests)
|
for (auto& it: m_LeaseSetRequests)
|
||||||
if (it.second->requestComplete) it.second->requestComplete (nullptr);
|
it.second->Complete (nullptr);
|
||||||
m_LeaseSetRequests.clear ();
|
m_LeaseSetRequests.clear ();
|
||||||
if (m_Pool)
|
if (m_Pool)
|
||||||
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool);
|
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool);
|
||||||
@ -345,7 +345,7 @@ namespace client
|
|||||||
if (it1 != m_LeaseSetRequests.end ())
|
if (it1 != m_LeaseSetRequests.end ())
|
||||||
{
|
{
|
||||||
it1->second->requestTimeoutTimer.cancel ();
|
it1->second->requestTimeoutTimer.cancel ();
|
||||||
if (it1->second->requestComplete) it1->second->requestComplete (leaseSet);
|
if (it1->second) it1->second->Complete (leaseSet);
|
||||||
m_LeaseSetRequests.erase (it1);
|
m_LeaseSetRequests.erase (it1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ namespace client
|
|||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Destination: ", key.ToBase64 (), " was not found on ", MAX_NUM_FLOODFILLS_PER_REQUEST, " floodfills");
|
LogPrint (eLogInfo, "Destination: ", key.ToBase64 (), " was not found on ", MAX_NUM_FLOODFILLS_PER_REQUEST, " floodfills");
|
||||||
if (request->requestComplete) request->requestComplete (nullptr);
|
request->Complete (nullptr);
|
||||||
m_LeaseSetRequests.erase (key);
|
m_LeaseSetRequests.erase (key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,9 +512,9 @@ namespace client
|
|||||||
auto it = s->m_LeaseSetRequests.find (dest);
|
auto it = s->m_LeaseSetRequests.find (dest);
|
||||||
if (it != s->m_LeaseSetRequests.end ())
|
if (it != s->m_LeaseSetRequests.end ())
|
||||||
{
|
{
|
||||||
auto requestComplete = it->second->requestComplete;
|
auto requestComplete = it->second;
|
||||||
s->m_LeaseSetRequests.erase (it);
|
s->m_LeaseSetRequests.erase (it);
|
||||||
if (notify && requestComplete) requestComplete (nullptr);
|
if (notify && requestComplete) requestComplete->Complete (nullptr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -526,7 +526,7 @@ namespace client
|
|||||||
if (floodfill)
|
if (floodfill)
|
||||||
{
|
{
|
||||||
auto request = std::make_shared<LeaseSetRequest> (m_Service);
|
auto request = std::make_shared<LeaseSetRequest> (m_Service);
|
||||||
request->requestComplete = requestComplete;
|
request->requestComplete.push_back (requestComplete);
|
||||||
auto ret = m_LeaseSetRequests.insert (std::pair<i2p::data::IdentHash, std::shared_ptr<LeaseSetRequest> >(dest,request));
|
auto ret = m_LeaseSetRequests.insert (std::pair<i2p::data::IdentHash, std::shared_ptr<LeaseSetRequest> >(dest,request));
|
||||||
if (ret.second) // inserted
|
if (ret.second) // inserted
|
||||||
{
|
{
|
||||||
@ -534,20 +534,19 @@ namespace client
|
|||||||
{
|
{
|
||||||
// request failed
|
// request failed
|
||||||
m_LeaseSetRequests.erase (dest);
|
m_LeaseSetRequests.erase (dest);
|
||||||
if (request->requestComplete) request->requestComplete (nullptr);
|
requestComplete (nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // duplicate
|
else // duplicate
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Destination: Request of LeaseSet ", dest.ToBase64 (), " is pending already");
|
LogPrint (eLogInfo, "Destination: Request of LeaseSet ", dest.ToBase64 (), " is pending already");
|
||||||
// TODO: queue up requests
|
ret.first->second->requestComplete.push_back (requestComplete);
|
||||||
if (request->requestComplete) request->requestComplete (nullptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Destination: Can't request LeaseSet, no floodfills found");
|
LogPrint (eLogError, "Destination: Can't request LeaseSet, no floodfills found");
|
||||||
if (requestComplete) requestComplete (nullptr);
|
requestComplete (nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,9 +621,9 @@ namespace client
|
|||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
auto requestComplete = it->second->requestComplete;
|
auto requestComplete = it->second;
|
||||||
m_LeaseSetRequests.erase (it);
|
m_LeaseSetRequests.erase (it);
|
||||||
if (requestComplete) requestComplete (nullptr);
|
if (requestComplete) requestComplete->Complete (nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,15 @@ namespace client
|
|||||||
std::set<i2p::data::IdentHash> excluded;
|
std::set<i2p::data::IdentHash> excluded;
|
||||||
uint64_t requestTime;
|
uint64_t requestTime;
|
||||||
boost::asio::deadline_timer requestTimeoutTimer;
|
boost::asio::deadline_timer requestTimeoutTimer;
|
||||||
RequestComplete requestComplete;
|
std::list<RequestComplete> requestComplete;
|
||||||
std::shared_ptr<i2p::tunnel::OutboundTunnel> outboundTunnel;
|
std::shared_ptr<i2p::tunnel::OutboundTunnel> outboundTunnel;
|
||||||
std::shared_ptr<i2p::tunnel::InboundTunnel> replyTunnel;
|
std::shared_ptr<i2p::tunnel::InboundTunnel> replyTunnel;
|
||||||
|
|
||||||
|
void Complete (std::shared_ptr<i2p::data::LeaseSet> ls)
|
||||||
|
{
|
||||||
|
for (auto& it: requestComplete) it (ls);
|
||||||
|
requestComplete.clear ();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user