Browse Source

30 seconds timeout for exploratory requests

pull/1941/merge
orignal 8 months ago
parent
commit
ba22a940f1
  1. 5
      libi2pd/NetDbRequests.cpp
  2. 1
      libi2pd/NetDbRequests.h

5
libi2pd/NetDbRequests.cpp

@ -181,6 +181,8 @@ namespace data
{ {
auto& dest = it->second; auto& dest = it->second;
bool done = false; bool done = false;
if (!dest->IsExploratory ())
{
if (ts < dest->GetCreationTime () + MAX_REQUEST_TIME) // request becomes worthless if (ts < dest->GetCreationTime () + MAX_REQUEST_TIME) // request becomes worthless
{ {
if (ts > dest->GetLastRequestTime () + MIN_REQUEST_TIME) // try next floodfill if no response after min interval if (ts > dest->GetLastRequestTime () + MIN_REQUEST_TIME) // try next floodfill if no response after min interval
@ -188,6 +190,9 @@ namespace data
} }
else // delete obsolete request else // delete obsolete request
done = true; done = true;
}
else if (ts >= dest->GetCreationTime () + MAX_EXPLORATORY_REQUEST_TIME)
done = true;
if (done) if (done)
it = m_RequestedDestinations.erase (it); it = m_RequestedDestinations.erase (it);

1
libi2pd/NetDbRequests.h

@ -24,6 +24,7 @@ namespace data
const uint64_t MANAGE_REQUESTS_INTERVAL = 1; // in seconds const uint64_t MANAGE_REQUESTS_INTERVAL = 1; // in seconds
const uint64_t MIN_REQUEST_TIME = 5; // in seconds const uint64_t MIN_REQUEST_TIME = 5; // in seconds
const uint64_t MAX_REQUEST_TIME = MAX_NUM_REQUEST_ATTEMPTS * (MIN_REQUEST_TIME + MANAGE_REQUESTS_INTERVAL); const uint64_t MAX_REQUEST_TIME = MAX_NUM_REQUEST_ATTEMPTS * (MIN_REQUEST_TIME + MANAGE_REQUESTS_INTERVAL);
const uint64_t MAX_EXPLORATORY_REQUEST_TIME = 30; // in seconds
class RequestedDestination class RequestedDestination
{ {

Loading…
Cancel
Save