Only sort sessions during Drain() if a random seed is set

This commit is contained in:
Tim Wojtulewicz 2021-08-03 10:07:47 -07:00
parent e2dc6df8a2
commit 201617540d

View file

@ -217,6 +217,11 @@ void Manager::Insert(Session* s, bool remove_existing)
}
void Manager::Drain()
{
// If a random seed was passed in, we're most likely in testing mode and need the
// order of the sessions to be consistent. Sort the keys to force that order
// every run.
if ( zeek::util::detail::have_random_seed() )
{
std::vector<const detail::Key*> keys;
keys.reserve(session_map.size());
@ -233,6 +238,16 @@ void Manager::Drain()
tc->RemovalEvent();
}
}
else
{
for ( const auto& entry : session_map )
{
Session* tc = entry.second;
tc->Done();
tc->RemovalEvent();
}
}
}
void Manager::Clear()
{