From: Christian Herdtweck Date: Mon, 12 Jan 2015 14:43:38 +0000 (+0100) Subject: introduce a max number of exceptions ignored in io_service main loop X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=ce330b206563f9cf4be3e015c6bef9956beb810a;p=pingcheck introduce a max number of exceptions ignored in io_service main loop mainly for testing and debugging --- diff --git a/src/main.cpp b/src/main.cpp index 34183ad..4ad6ce6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -446,6 +446,7 @@ int main( int argc, const char *argv[] ) IoServiceItem io_service; int ret_code = 0; unsigned n_exceptions = 0; + unsigned max_exceptions = 1; try { ConfigurationItem configuration = get_configuration( argc, argv ); @@ -511,6 +512,14 @@ int main( int argc, const char *argv[] ) ++n_exceptions; GlobalLogger.error() << "Caught unknown exception, will continue!" << endl; } + + if (max_exceptions > 0 && n_exceptions >= max_exceptions) + { + GlobalLogger.info() << "reached max number of exceptions allowed in main loop" << endl; + io_service->stop(); + signal_data.stopped = true; + break; + } } }