1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

HandleTimeout can touch iterators so do all handling of lookup timeouts outside of loop iteration

This commit is contained in:
Jeff Becker 2021-06-03 17:51:23 -04:00
parent 0f1e806155
commit 108b8e089e
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05

View file

@ -37,6 +37,7 @@ namespace llarp
void
EndpointUtil::ExpirePendingTx(llarp_time_t now, PendingLookups& lookups)
{
std::vector<std::unique_ptr<IServiceLookup>> timedout;
for (auto itr = lookups.begin(); itr != lookups.end();)
{
if (!itr->second->IsTimedOut(now))
@ -44,11 +45,14 @@ namespace llarp
++itr;
continue;
}
std::unique_ptr<IServiceLookup> lookup = std::move(itr->second);
timedout.emplace_back(std::move(itr->second));
itr = lookups.erase(itr);
}
for (const auto& lookup : timedout)
{
LogWarn(lookup->name, " timed out txid=", lookup->txid);
lookup->HandleTimeout();
itr = lookups.erase(itr);
}
}