mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Force the Broker IOSource to idle periodically
Previously, if there was always input in each Process() call, then the Broker IOSource would never go idle and could completely starve out a packet IOSource since it would always report readiness with a timestamp value of the last known network_time (which prevents selecting a packet IOSource for processing, due to incoming packets likely having timestamps that are later).
This commit is contained in:
parent
9a461d26e4
commit
32473b85b0
2 changed files with 28 additions and 1 deletions
|
@ -140,6 +140,7 @@ Manager::Manager(bool arg_reading_pcaps)
|
|||
reading_pcaps = arg_reading_pcaps;
|
||||
after_zeek_init = false;
|
||||
peer_count = 0;
|
||||
times_processed_without_idle = 0;
|
||||
log_topic_func = nullptr;
|
||||
vector_of_data_type = nullptr;
|
||||
log_id_type = nullptr;
|
||||
|
@ -942,7 +943,32 @@ void Manager::Process()
|
|||
}
|
||||
}
|
||||
|
||||
SetIdle(! had_input);
|
||||
if ( had_input )
|
||||
{
|
||||
++times_processed_without_idle;
|
||||
|
||||
// The max number of Process calls allowed to happen in a row without
|
||||
// idling is chosen a bit arbitrarily, except 12 is around half of the
|
||||
// SELECT_FREQUENCY (25).
|
||||
//
|
||||
// But probably the general idea should be for it to have some relation
|
||||
// to the SELECT_FREQUENCY: less than it so other busy IOSources can
|
||||
// fit several Process loops in before the next poll event (e.g. the
|
||||
// select() call ), but still large enough such that we don't have to
|
||||
// wait long before the next poll ourselves after being forced to idle.
|
||||
if ( times_processed_without_idle > 12 )
|
||||
{
|
||||
times_processed_without_idle = 0;
|
||||
SetIdle(true);
|
||||
}
|
||||
else
|
||||
SetIdle(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
times_processed_without_idle = 0;
|
||||
SetIdle(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -382,6 +382,7 @@ private:
|
|||
bool reading_pcaps;
|
||||
bool after_zeek_init;
|
||||
int peer_count;
|
||||
int times_processed_without_idle;
|
||||
|
||||
Func* log_topic_func;
|
||||
VectorType* vector_of_data_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue