Skip to content

Commit

Permalink
fixed potential race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 5, 2024
1 parent 58245bf commit 0710f62
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libi2pd/SSU2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,8 +1336,11 @@ namespace transport

// exclude all existing sessions
excluded.clear ();
for (const auto& [ident, s] : m_SessionsByRouterHash)
excluded.insert (ident);
{
std::lock_guard<std::mutex> l(m_SessionsByRouterHashMutex);
for (const auto& [ident, s] : m_SessionsByRouterHash)
excluded.insert (ident);
}

// sesssion about to expire are not counted
for (auto i = introducers.size (); i < SSU2_MAX_NUM_INTRODUCERS + numOldSessions; i++)
Expand Down

0 comments on commit 0710f62

Please sign in to comment.