From d3e9685de3fd1fc4f5cc63d4d2e9006f44aebd75 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 12 Oct 2010 16:03:56 +0000 Subject: Catch uncaught exceptions thrown by DispatchHandle callbacks instead of letting then destroy the Poller thread. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1021814 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/DispatchHandle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/DispatchHandle.cpp b/cpp/src/qpid/sys/DispatchHandle.cpp index 95da87aa28..554fc382ed 100644 --- a/cpp/src/qpid/sys/DispatchHandle.cpp +++ b/cpp/src/qpid/sys/DispatchHandle.cpp @@ -20,6 +20,7 @@ */ #include "qpid/sys/DispatchHandle.h" +#include "qpid/log/Statement.h" #include @@ -273,6 +274,7 @@ void DispatchHandle::processEvent(Poller::EventType type) { // Do callbacks - whilst we are doing the callbacks we are prevented from processing // the same handle until we re-enable it. To avoid rentering the callbacks for a single // handle re-enabling in the callbacks is actually deferred until they are complete. + try { switch (type) { case Poller::READABLE: readableCallback(*this); @@ -307,6 +309,11 @@ void DispatchHandle::processEvent(Poller::EventType type) { cb(*this); callbacks.pop(); } + } catch (std::exception& e) { + // One of the callbacks threw an exception - that's not allowed + QPID_LOG(error, "Caught exception in state: " << state << " with event: " << type << ": " << e.what()); + // It would be nice to clean up and delete ourselves here, but we can't + } { ScopedLock lock(stateLock); -- cgit v1.2.1