Author: aconway
Date: Wed Feb 25 14:11:19 2009
New Revision: 747789

URL: http://svn.apache.org/viewvc?rev=747789&view=rev
Log:
Fix race condition: move all calls on Decoder into event delivery thread.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp?rev=747789&r1=747788&r2=747789&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp Wed Feb 25 14:11:19 2009
@@ -163,7 +163,6 @@
 void Cluster::erase(const ConnectionId& id) {
     // Called only by Connection::deliverClose in deliver thread, no need to 
lock.
     connections.erase(id);
-    decoder.erase(id);
 }
 
 std::vector<string> Cluster::getIds() const {
@@ -231,9 +230,14 @@
     Buffer buf(const_cast<char*>(e.getData()), e.getSize());
     if (e.getType() == CONTROL) {
         AMQFrame frame;
-        while (frame.decode(buf)) 
+        while (frame.decode(buf)) {
+            // Check for deliver close here so we can erase the
+            // connection decoder safely in this thread.
+            if (frame.getMethod()->isA<ClusterConnectionDeliverCloseBody>())
+                decoder.erase(e.getConnectionId());
             deliverFrameQueue.push(EventFrame(e, frame));
     }
+    }
     else if (e.getType() == DATA)
         decoder.decode(e, e.getData());
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to