From ce330b206563f9cf4be3e015c6bef9956beb810a Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Mon, 12 Jan 2015 15:43:38 +0100 Subject: [PATCH] introduce a max number of exceptions ignored in io_service main loop mainly for testing and debugging --- src/main.cpp | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) 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; + } } } -- 1.7.1