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:
parent
0f1e806155
commit
108b8e089e
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue