Merge in SNORT/snort3 from ~RSHAFIQ/snort3:host_cache_pegs to master
Squashed commit of the following:
commit
2d742de0301f5940aa7f658336f382f33059f1e9
Author: rshafiq <rshafiq@cisco.com>
Date: Wed Dec 6 08:37:52 2023 -0500
host_cache: fix for race condition on peg counts
PegCount* pcs = (PegCount*)&counts;
const PegInfo* pegs = get_pegs();
- for ( int i = 0; pegs[i].type != CountType::END; i++ )
+ for (int i = 0; pegs[i].type != CountType::END; i++)
+ pcs[i] = 0;
+
+ for (auto cache : seg_list)
{
- PegCount c = 0;
- for(auto cache : seg_list)
- c += cache->get_counts()[i];
- pcs[i] = c;
+ const PegCount* cache_counts = cache->get_counts();
+ cache->lock();
+ for (int i = 0; pegs[i].type != CountType::END; i++)
+ pcs[i] += cache_counts[i];
+ cache->unlock();
}
}