diff --git a/scripts/base/init-bare.zeek b/scripts/base/init-bare.zeek index af5e9b08fb..b69880db55 100644 --- a/scripts/base/init-bare.zeek +++ b/scripts/base/init-bare.zeek @@ -5581,6 +5581,35 @@ const digest_salt = "Please change this value." &redef; ## :zeek:see:`find_all_ordered` BIFs. const max_find_all_string_length: int = 10000 &redef; +## How many rounds to go without checking IO sources with file descriptors +## for readiness by default. This is used when reading from traces. +## +## Very roughly, when reading from a pcap, setting this to 100 results in +## 100 packets being processed without checking FD based IO sources. +## +## .. note:: This should not be changed outside of development or when +## debugging problems with the main-loop, or developing features with +## tight main-loop interaction. +## +## .. zeek:see:: io_poll_interval_live +const io_poll_interval_default = 100 &redef; + +## How often to check IO sources with file descriptors for readiness when +## monitoring with a live packet source. +## +## The poll interval gets defaulted to 100 which is good for cases like reading +## from pcap files and when there isn't a packet source, but is a little too +## infrequent for live sources (especially fast live sources). Set it down a +## little bit for those sources. +## +## .. note:: This should not be changed outside of development or when +## debugging problems with the main-loop, or developing features with +## tight main-loop interaction. +## +## .. zeek:see:: io_poll_interval_default +const io_poll_interval_live = 10 &redef; + + global done_with_network = F; event net_done(t: time) { done_with_network = T; } diff --git a/src/const.bif b/src/const.bif index f28429b33c..4d793d82c1 100644 --- a/src/const.bif +++ b/src/const.bif @@ -11,6 +11,9 @@ const exit_only_after_terminate: bool; const digest_salt: string; const max_analyzer_violations: count; +const io_poll_interval_default: count; +const io_poll_interval_live: count; + const FTP::max_command_length: count; const NFS3::return_data: bool; diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index 537965674a..1cf2d9e599 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -105,6 +105,7 @@ Manager::~Manager() void Manager::InitPostScript() { wakeup = new WakeupHandler(); + poll_interval = BifConst::io_poll_interval_default; } void Manager::RemoveAll() @@ -401,12 +402,8 @@ void Manager::Register(PktSrc* src) { pkt_src = src; - // The poll interval gets defaulted to 100 which is good for cases like reading - // from pcap files and when there isn't a packet source, but is a little too - // infrequent for live sources (especially fast live sources). Set it down a - // little bit for those sources. if ( src->IsLive() ) - poll_interval = 10; + poll_interval = BifConst::io_poll_interval_live; else if ( run_state::pseudo_realtime ) poll_interval = 1; diff --git a/src/iosource/Manager.h b/src/iosource/Manager.h index 6fad1adcc5..dbfba845e7 100644 --- a/src/iosource/Manager.h +++ b/src/iosource/Manager.h @@ -216,7 +216,7 @@ private: int zero_timeout_count = 0; WakeupHandler* wakeup = nullptr; int poll_counter = 0; - int poll_interval = 100; + int poll_interval = 0; // Set in InitPostScript() based on const value. int event_queue = -1; std::map fd_map;