From 4f39470c1bc37cce69c597ba5d5a28e1bb0548e1 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Fri, 18 Jan 2013 17:34:33 -0800 Subject: [PATCH] New option exit_only_after_terminate to prevent Bro from exiting. If set, the main loop won't terminate before somebody calls terminate(). This should make input framework testing more reliable I'd hope. --- scripts/base/init-bare.bro | 9 +++++++++ src/Net.cc | 3 ++- src/const.bif | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/base/init-bare.bro b/scripts/base/init-bare.bro index e5365a9428..a01b52817c 100644 --- a/scripts/base/init-bare.bro +++ b/scripts/base/init-bare.bro @@ -2608,6 +2608,15 @@ const gap_report_freq = 1.0 sec &redef; ## .. bro:see:: content_gap gap_report partial_connection const report_gaps_for_partial = F &redef; +## Flag to prevent Bro from exiting automatically when input is exhausted. +## Normally Bro terminates when all packets sources have gone dry +## and communication isn't enabled. If this flag is set, Bro's main loop will +## instead keep idleing until :bro:see::`terminate` is explicitly called. +## +## This is mainly for testing purposes when termination behaviour needs to be +## controlled for reproducing results. +const exit_only_after_terminate = F &redef; + ## The CA certificate file to authorize remote Bros/Broccolis. ## ## .. bro:see:: ssl_private_key ssl_passphrase diff --git a/src/Net.cc b/src/Net.cc index 328998b011..73c618b8af 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -421,7 +421,8 @@ void net_run() set_processing_status("RUNNING", "net_run"); while ( io_sources.Size() || - (packet_sorter && ! packet_sorter->Empty()) ) + (packet_sorter && ! packet_sorter->Empty()) || + (BifConst::exit_only_after_terminate && ! terminating) ) { double ts; IOSource* src = io_sources.FindSoonest(&ts); diff --git a/src/const.bif b/src/const.bif index ea7dc03817..ea84b3363d 100644 --- a/src/const.bif +++ b/src/const.bif @@ -6,6 +6,7 @@ const ignore_keep_alive_rexmit: bool; const skip_http_data: bool; const use_conn_size_analyzer: bool; const report_gaps_for_partial: bool; +const exit_only_after_terminate: bool; const NFS3::return_data: bool; const NFS3::return_data_max: count;