You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2010/10/12 18:03:56 UTC

svn commit: r1021814 - /qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp

Author: astitcher
Date: Tue Oct 12 16:03:56 2010
New Revision: 1021814

URL: http://svn.apache.org/viewvc?rev=1021814&view=rev
Log:
Catch uncaught exceptions thrown by DispatchHandle callbacks instead of letting
then destroy the Poller thread.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp?rev=1021814&r1=1021813&r2=1021814&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/DispatchHandle.cpp Tue Oct 12 16:03:56 2010
@@ -20,6 +20,7 @@
  */
 
 #include "qpid/sys/DispatchHandle.h"
+#include "qpid/log/Statement.h"
 
 #include <algorithm>
 
@@ -273,6 +274,7 @@ void DispatchHandle::processEvent(Poller
     // 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
         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);



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org