Author: gsim
Date: Thu Nov 27 09:07:33 2008
New Revision: 721243

URL: http://svn.apache.org/viewvc?rev=721243&view=rev
Log:
QPID-1264: fix for topic exchange (patch from [EMAIL PROTECTED])


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/TopicExchange.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/TopicExchange.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/TopicExchange.cpp?rev=721243&r1=721242&r2=721243&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/TopicExchange.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/TopicExchange.cpp Thu Nov 27 
09:07:33 2008
@@ -240,21 +240,29 @@
 }
 
 void TopicExchange::route(Deliverable& msg, const string& routingKey, const 
FieldTable* /*args*/){
-    RWlock::ScopedRlock l(lock);
+    Binding::vector mb;
     PreRoute pr(msg, this);
     uint32_t count(0);
+
+    {
+    RWlock::ScopedRlock l(lock);
     Tokens   tokens(routingKey);
 
     for (BindingMap::iterator i = bindings.begin(); i != bindings.end(); ++i) {
         if (i->first.match(tokens)) {
             Binding::vector& qv(i->second.bindingVector);
             for(Binding::vector::iterator j = qv.begin(); j != qv.end(); j++, 
count++){
-                msg.deliverTo((*j)->queue);
-                if ((*j)->mgmtBinding != 0)
-                    (*j)->mgmtBinding->inc_msgMatched ();
+                mb.push_back(*j);
             }
         }
     }
+    }
+    
+    for (Binding::vector::iterator j = mb.begin(); j != mb.end(); ++j) {
+        msg.deliverTo((*j)->queue);
+        if ((*j)->mgmtBinding != 0)
+            (*j)->mgmtBinding->inc_msgMatched ();
+    }
 
     if (mgmtExchange != 0)
     {


Reply via email to