[icinga-checkins] icinga.org: icinga2/master: Catch exceptions in EventQueue::QueueThreadProc .

git at icinga.org git at icinga.org
Fri Mar 8 14:44:15 CET 2013


Module: icinga2
Branch: master
Commit: 13436cb53610dc023fadf4370f4bcf789061be59
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=13436cb53610dc023fadf4370f4bcf789061be59

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Mar  8 14:43:07 2013 +0100

Catch exceptions in EventQueue::QueueThreadProc.

---

 lib/base/eventqueue.cpp |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/lib/base/eventqueue.cpp b/lib/base/eventqueue.cpp
index 921310e..ba58ad0 100644
--- a/lib/base/eventqueue.cpp
+++ b/lib/base/eventqueue.cpp
@@ -103,7 +103,17 @@ void EventQueue::QueueThreadProc(void)
 #	endif /* RUSAGE_THREAD */
 #endif /* _DEBUG */
 
-			ev();
+			try {
+				ev();
+			} catch (const std::exception& ex) {
+				stringstream msgbuf;
+				msgbuf << "Exception thrown in event handler: " << std::endl
+				       << diagnostic_information(ex);
+
+				Logger::Write(LogCritical, "base", msgbuf.str());
+			} catch (...) {
+				Logger::Write(LogCritical, "base", "Exception of unknown type thrown in event handler.");
+			}
 
 #ifdef _DEBUG
 			double et = Utility::GetTime();





More information about the icinga-checkins mailing list