mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -3,35 +3,30 @@
|
|||
#include "zeek/RunState.h"
|
||||
#include "zeek/util.h"
|
||||
|
||||
namespace zeek::detail
|
||||
{
|
||||
namespace zeek::detail {
|
||||
|
||||
bool PermitWeird(WeirdStateMap& wsm, const char* name, uint64_t threshold, uint64_t rate,
|
||||
double duration)
|
||||
{
|
||||
auto& state = wsm[name];
|
||||
++state.count;
|
||||
bool PermitWeird(WeirdStateMap& wsm, const char* name, uint64_t threshold, uint64_t rate, double duration) {
|
||||
auto& state = wsm[name];
|
||||
++state.count;
|
||||
|
||||
if ( state.count <= threshold )
|
||||
return true;
|
||||
if ( state.count <= threshold )
|
||||
return true;
|
||||
|
||||
if ( state.count == threshold + 1 )
|
||||
state.sampling_start_time = run_state::network_time;
|
||||
else
|
||||
{
|
||||
if ( run_state::network_time > state.sampling_start_time + duration )
|
||||
{
|
||||
state.sampling_start_time = 0;
|
||||
state.count = 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ( state.count == threshold + 1 )
|
||||
state.sampling_start_time = run_state::network_time;
|
||||
else {
|
||||
if ( run_state::network_time > state.sampling_start_time + duration ) {
|
||||
state.sampling_start_time = 0;
|
||||
state.count = 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto num_above_threshold = state.count - threshold;
|
||||
if ( rate )
|
||||
return num_above_threshold % rate == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
auto num_above_threshold = state.count - threshold;
|
||||
if ( rate )
|
||||
return num_above_threshold % rate == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace zeek::detail
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue