mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Only sort sessions during Drain() if a random seed is set
This commit is contained in:
parent
e2dc6df8a2
commit
201617540d
1 changed files with 27 additions and 12 deletions
|
@ -218,19 +218,34 @@ void Manager::Insert(Session* s, bool remove_existing)
|
|||
|
||||
void Manager::Drain()
|
||||
{
|
||||
std::vector<const detail::Key*> keys;
|
||||
keys.reserve(session_map.size());
|
||||
|
||||
for ( auto& entry : session_map )
|
||||
keys.push_back(&(entry.first));
|
||||
std::sort(keys.begin(), keys.end(), [](const detail::Key* a, const detail::Key* b) {
|
||||
return *a < *b; });
|
||||
|
||||
for ( const auto* k : keys )
|
||||
// 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() )
|
||||
{
|
||||
Session* tc = session_map.at(*k);
|
||||
tc->Done();
|
||||
tc->RemovalEvent();
|
||||
std::vector<const detail::Key*> keys;
|
||||
keys.reserve(session_map.size());
|
||||
|
||||
for ( auto& entry : session_map )
|
||||
keys.push_back(&(entry.first));
|
||||
std::sort(keys.begin(), keys.end(), [](const detail::Key* a, const detail::Key* b) {
|
||||
return *a < *b; });
|
||||
|
||||
for ( const auto* k : keys )
|
||||
{
|
||||
Session* tc = session_map.at(*k);
|
||||
tc->Done();
|
||||
tc->RemovalEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( const auto& entry : session_map )
|
||||
{
|
||||
Session* tc = entry.second;
|
||||
tc->Done();
|
||||
tc->RemovalEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue