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 | bcf92981584daac3238432f1c571201e8de41cea (patch) | |
tree | df57ec9a4d0458b9aa850b69de672ec45043feb8 | |
parent | 44f7d864ee9fb58a8186740d0045a744c0d5b922 (diff) | |
download | qpid-python-bcf92981584daac3238432f1c571201e8de41cea.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@1021814 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/sys/DispatchHandle.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/sys/DispatchHandle.cpp b/qpid/cpp/src/qpid/sys/DispatchHandle.cpp index 95da87aa28..554fc382ed 100644 --- a/qpid/cpp/src/qpid/sys/DispatchHandle.cpp +++ b/qpid/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); |