activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1336956 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Date Thu, 10 May 2012 23:32:19 GMT
Author: tabish
Date: Thu May 10 23:32:19 2012
New Revision: 1336956

URL: http://svn.apache.org/viewvc?rev=1336956&view=rev
Log:
work around a race condition. 

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=1336956&r1=1336955&r2=1336956&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Thu May 10 23:32:19 2012
@@ -424,7 +424,9 @@ Pointer<SessionId> ActiveMQConnection::g
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQConnection::addSession(Pointer<ActiveMQSessionKernel> session) {
     try {
-        this->config->activeSessions.add(session);
+        synchronized(&this->config->activeSessions) {
+            this->config->activeSessions.add(session);
+        }
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
@@ -432,7 +434,9 @@ void ActiveMQConnection::addSession(Poin
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQConnection::removeSession(Pointer<ActiveMQSessionKernel> session) {
     try {
-        this->config->activeSessions.remove(session);
+        synchronized(&this->config->activeSessions) {
+            this->config->activeSessions.remove(session);
+        }
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
@@ -618,10 +622,13 @@ void ActiveMQConnection::start() {
         // and not acknowledged.
         if (this->started.compareAndSet(false, true)) {
 
-            // Start all the sessions.
-            std::auto_ptr<Iterator< Pointer<ActiveMQSessionKernel> > >
iter(this->config->activeSessions.iterator());
-            while (iter->hasNext()) {
-                iter->next()->start();
+            synchronized(&this->config->activeSessions) {
+
+                // Start all the sessions.
+                std::auto_ptr<Iterator< Pointer<ActiveMQSessionKernel> > >
iter(this->config->activeSessions.iterator());
+                while (iter->hasNext()) {
+                    iter->next()->start();
+                }
             }
         }
     }



Mime
View raw message