mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +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()
|
void Manager::Drain()
|
||||||
{
|
{
|
||||||
std::vector<const detail::Key*> keys;
|
// If a random seed was passed in, we're most likely in testing mode and need the
|
||||||
keys.reserve(session_map.size());
|
// order of the sessions to be consistent. Sort the keys to force that order
|
||||||
|
// every run.
|
||||||
for ( auto& entry : session_map )
|
if ( zeek::util::detail::have_random_seed() )
|
||||||
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);
|
std::vector<const detail::Key*> keys;
|
||||||
tc->Done();
|
keys.reserve(session_map.size());
|
||||||
tc->RemovalEvent();
|
|
||||||
|
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