Merge remote-tracking branch 'origin/topic/jsiwek/force-idle-broker'

* origin/topic/jsiwek/force-idle-broker:
  Force the Broker IOSource to idle periodically
This commit is contained in:
Johanna Amann 2019-05-08 09:03:27 -07:00
commit 312713810f
4 changed files with 34 additions and 2 deletions

View file

@ -1,4 +1,9 @@
2.6-276 | 2019-05-08 09:03:27 -0700
* Force the Broker IOSource to idle periodically, preventing packet
IOSource starvation. (Jon Siwek, Corelight).
2.6-274 | 2019-05-08 08:58:25 -0700 2.6-274 | 2019-05-08 08:58:25 -0700
* GH-353: Add `/<re>/i` case-insensitive signature syntax (Jon Siwek, Corelight) * GH-353: Add `/<re>/i` case-insensitive signature syntax (Jon Siwek, Corelight)

View file

@ -1 +1 @@
2.6-274 2.6-276

View file

@ -140,6 +140,7 @@ Manager::Manager(bool arg_reading_pcaps)
reading_pcaps = arg_reading_pcaps; reading_pcaps = arg_reading_pcaps;
after_zeek_init = false; after_zeek_init = false;
peer_count = 0; peer_count = 0;
times_processed_without_idle = 0;
log_topic_func = nullptr; log_topic_func = nullptr;
vector_of_data_type = nullptr; vector_of_data_type = nullptr;
log_id_type = nullptr; log_id_type = nullptr;
@ -944,7 +945,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);
}
} }

View file

@ -383,6 +383,7 @@ private:
bool reading_pcaps; bool reading_pcaps;
bool after_zeek_init; bool after_zeek_init;
int peer_count; int peer_count;
int times_processed_without_idle;
Func* log_topic_func; Func* log_topic_func;
VectorType* vector_of_data_type; VectorType* vector_of_data_type;