From 6a60f484f9faa3925cfc297e38f1f06561f41607 Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Thu, 29 Mar 2012 09:03:33 -0700 Subject: [PATCH 1/2] make heart beat interval for threading configureable from scripting layer --- scripts/base/init-bare.bro | 8 ++++++++ src/const.bif | 1 + src/threading/Manager.cc | 6 +++++- src/threading/Manager.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/base/init-bare.bro b/scripts/base/init-bare.bro index 9f4e0355f0..77f90cae5f 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 &redef; +} + module GLOBAL; ## An NTP message. diff --git a/src/const.bif b/src/const.bif index bc960caeb6..aadb1e1ab7 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: double; diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index d008d2e5e8..8546ca3948 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 = false; + + heart_beat_interval = double(BifConst::Threading::heart_beat_interval); + DBG_LOG(DBG_THREADING, "Heart beat interval set to %f", heart_beat_interval); } Manager::~Manager() @@ -73,7 +77,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 7d9ba766d4..29729f6a7a 100644 --- a/src/threading/Manager.h +++ b/src/threading/Manager.h @@ -120,7 +120,7 @@ protected: virtual const char* Tag() { return "threading::Manager"; } private: - static const int HEART_BEAT_INTERVAL = 1; + int heart_beat_interval; typedef std::list all_thread_list; all_thread_list all_threads; From ead30e423d0316e1e2e05ae5334f7771d1582f5c Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Fri, 30 Mar 2012 08:40:38 -0700 Subject: [PATCH 2/2] change type of heart_beat_interval to interval (makes much more sese) --- scripts/base/init-bare.bro | 2 +- src/const.bif | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/base/init-bare.bro b/scripts/base/init-bare.bro index 3a5b2023dd..4637580337 100644 --- a/scripts/base/init-bare.bro +++ b/scripts/base/init-bare.bro @@ -1489,7 +1489,7 @@ 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 &redef; + const heart_beat_interval = 1.0 secs &redef; } module GLOBAL; diff --git a/src/const.bif b/src/const.bif index aadb1e1ab7..f9e5f61644 100644 --- a/src/const.bif +++ b/src/const.bif @@ -12,4 +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: double; +const Threading::heart_beat_interval: interval;