diff options
author | Andrew Stitcher <astitcher@apache.org> | 2010-10-12 16:03:56 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2010-10-12 16:03:56 +0000 |
commit | d3e9685de3fd1fc4f5cc63d4d2e9006f44aebd75 (patch) | |
tree | 31e9f6ae19fcafe181aba73cc7096a7bd8bb5aea /cpp/src | |
parent | 93d1a5bae66d807920ed4b5e238f487fc017a247 (diff) | |
download | qpid-python-d3e9685de3fd1fc4f5cc63d4d2e9006f44aebd75.tar.gz |
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
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/sys/DispatchHandle.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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 <algorithm> @@ -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<Mutex> lock(stateLock); |