diff --git a/scripts/base/init-bare.bro b/scripts/base/init-bare.bro index 2b8f278934..4e0d2e73a4 100644 --- a/scripts/base/init-bare.bro +++ b/scripts/base/init-bare.bro @@ -1484,6 +1484,14 @@ export { }; } # end export +module Threading; + +export { + ## The heart beat interval used by the threading framework. + ## Changing this should usually not be neccessary and will break several tests. + const heart_beat_interval = 1.0 secs &redef; +} + module GLOBAL; ## An NTP message. diff --git a/src/const.bif b/src/const.bif index bc960caeb6..f9e5f61644 100644 --- a/src/const.bif +++ b/src/const.bif @@ -12,3 +12,4 @@ const NFS3::return_data: bool; const NFS3::return_data_max: count; const NFS3::return_data_first_only: bool; +const Threading::heart_beat_interval: interval; diff --git a/src/input/readers/Benchmark.cc b/src/input/readers/Benchmark.cc index 118b57f616..f0cebd2dc1 100644 --- a/src/input/readers/Benchmark.cc +++ b/src/input/readers/Benchmark.cc @@ -89,7 +89,7 @@ double Benchmark::CurrTime() { // read the entire file and send appropriate thingies back to InputMgr bool Benchmark::DoUpdate() { - int linestosend = num_lines * threading::Manager::HEART_BEAT_INTERVAL; + int linestosend = num_lines * heart_beat_interval; for ( int i = 0; i < linestosend; i++ ) { Value** field = new Value*[num_fields]; for (unsigned int j = 0; j < num_fields; j++ ) { @@ -117,7 +117,7 @@ bool Benchmark::DoUpdate() { diff = CurrTime() - heartbeatstarttime; //printf("%d %f\n", i, diff); //} while ( diff < i/threading::Manager::HEART_BEAT_INTERVAL*(num_lines + (num_lines * timedspread) ) ); - } while ( diff/threading::Manager::HEART_BEAT_INTERVAL < i/(linestosend + (linestosend * timedspread) ) ); + } while ( diff/heart_beat_interval < i/(linestosend + (linestosend * timedspread) ) ); //} while ( diff < 0.8); } diff --git a/src/input/readers/Benchmark.h b/src/input/readers/Benchmark.h index ca248586da..3133224313 100644 --- a/src/input/readers/Benchmark.h +++ b/src/input/readers/Benchmark.h @@ -46,6 +46,7 @@ private: int stopspreadat; double heartbeatstarttime; double timedspread; + double heart_beat_interval; string RandomString(const int len); diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 6a539861be..ec7ab34d14 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -1,5 +1,6 @@ #include "Manager.h" +#include "NetVar.h" using namespace threading; @@ -11,6 +12,9 @@ Manager::Manager() next_beat = 0; terminating = false; idle = true; + + heart_beat_interval = double(BifConst::Threading::heart_beat_interval); + DBG_LOG(DBG_THREADING, "Heart beat interval set to %f", heart_beat_interval); } Manager::~Manager() @@ -74,7 +78,7 @@ void Manager::GetFds(int* read, int* write, int* except) double Manager::NextTimestamp(double* network_time) { if ( ::network_time && ! next_beat ) - next_beat = ::network_time + HEART_BEAT_INTERVAL; + next_beat = ::network_time + heart_beat_interval; // fprintf(stderr, "N %.6f %.6f did_process=%d next_next=%.6f\n", ::network_time, timer_mgr->Time(), (int)did_process, next_beat); diff --git a/src/threading/Manager.h b/src/threading/Manager.h index d5d78b288a..541b6d34dc 100644 --- a/src/threading/Manager.h +++ b/src/threading/Manager.h @@ -124,9 +124,8 @@ protected: */ virtual const char* Tag() { return "threading::Manager"; } - static const int HEART_BEAT_INTERVAL = 10; - private: + int heart_beat_interval; typedef std::list all_thread_list; all_thread_list all_threads;