You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/03/29 20:16:45 UTC
svn commit: r1307024 - in
/activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq:
cmsutil/ResourceLifecycleManager.cpp core/ActiveMQConnection.cpp
Author: tabish
Date: Thu Mar 29 18:16:44 2012
New Revision: 1307024
URL: http://svn.apache.org/viewvc?rev=1307024&view=rev
Log:
Some fixes for: https://issues.apache.org/jira/browse/AMQCPP-388
Modified:
activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Modified: activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp?rev=1307024&r1=1307023&r2=1307024&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp Thu Mar 29 18:16:44 2012
@@ -71,73 +71,76 @@ void ResourceLifecycleManager::releaseAl
void ResourceLifecycleManager::destroy() {
try{
- // Close all the connections.
- std::auto_ptr< decaf::util::Iterator< cms::Connection* > > connIter(
- connections.iterator() );
-
- while( connIter->hasNext() ) {
- cms::Connection* conn = connIter->next();
- try {
- conn->close();
- } catch(...){}
- }
-
- // Destroy the producers.
- std::auto_ptr< decaf::util::Iterator< cms::MessageProducer* > > prodIter(
- producers.iterator() );
-
- while( prodIter->hasNext() ) {
- cms::MessageProducer* producer = prodIter->next();
- try {
- delete producer;
- } catch( ... ) {}
- }
-
- // Destroy the consumers.
- std::auto_ptr< decaf::util::Iterator< cms::MessageConsumer* > > consIter(
- consumers.iterator() );
-
- while( consIter->hasNext() ) {
- cms::MessageConsumer* consumer = consIter->next();
- try {
- delete consumer;
- } catch( ... ) {}
- }
-
- // Destroy the destinations.
- std::auto_ptr< decaf::util::Iterator< cms::Destination* > > destIter(
- destinations.iterator() );
-
- while( destIter->hasNext() ) {
- cms::Destination* dest = destIter->next();
- try {
- delete dest;
- } catch( ... ) {}
- }
-
- // Destroy the sessions.
- std::auto_ptr< decaf::util::Iterator< cms::Session* > > sessIter(
- sessions.iterator() );
-
- while( sessIter->hasNext() ) {
- cms::Session* session = sessIter->next();
- try {
- delete session;
- } catch( ... ) {}
- }
-
- // Destroy the connections,
- connIter.reset( connections.iterator() );
-
- while( connIter->hasNext() ) {
- cms::Connection* conn = connIter->next();
- try {
- delete conn;
- } catch( ... ) {}
- }
- // Empty all the lists.
- releaseAll();
+ synchronized(&connections) {
+ // Close all the connections.
+ std::auto_ptr< decaf::util::Iterator< cms::Connection* > > connIter(
+ connections.iterator() );
+
+ while( connIter->hasNext() ) {
+ cms::Connection* conn = connIter->next();
+ try {
+ conn->close();
+ } catch(...){}
+ }
+
+ // Destroy the producers.
+ std::auto_ptr< decaf::util::Iterator< cms::MessageProducer* > > prodIter(
+ producers.iterator() );
+
+ while( prodIter->hasNext() ) {
+ cms::MessageProducer* producer = prodIter->next();
+ try {
+ delete producer;
+ } catch( ... ) {}
+ }
+
+ // Destroy the consumers.
+ std::auto_ptr< decaf::util::Iterator< cms::MessageConsumer* > > consIter(
+ consumers.iterator() );
+
+ while( consIter->hasNext() ) {
+ cms::MessageConsumer* consumer = consIter->next();
+ try {
+ delete consumer;
+ } catch( ... ) {}
+ }
+
+ // Destroy the destinations.
+ std::auto_ptr< decaf::util::Iterator< cms::Destination* > > destIter(
+ destinations.iterator() );
+
+ while( destIter->hasNext() ) {
+ cms::Destination* dest = destIter->next();
+ try {
+ delete dest;
+ } catch( ... ) {}
+ }
+
+ // Destroy the sessions.
+ std::auto_ptr< decaf::util::Iterator< cms::Session* > > sessIter(
+ sessions.iterator() );
+
+ while( sessIter->hasNext() ) {
+ cms::Session* session = sessIter->next();
+ try {
+ delete session;
+ } catch( ... ) {}
+ }
+
+ // Destroy the connections,
+ connIter.reset( connections.iterator() );
+
+ while( connIter->hasNext() ) {
+ cms::Connection* conn = connIter->next();
+ try {
+ delete conn;
+ } catch( ... ) {}
+ }
+
+ // Empty all the lists.
+ releaseAll();
+ }
}
CMSTEMPLATE_CATCHALL()
}
Modified: activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=1307024&r1=1307023&r2=1307024&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp Thu Mar 29 18:16:44 2012
@@ -314,8 +314,10 @@ void ActiveMQConnection::addSession( Act
try {
- // Remove this session from the set of active sessions.
- this->config->activeSessions.add( session );
+ synchronized( &this->config->activeSessions ) {
+ // Remove this session from the set of active sessions.
+ this->config->activeSessions.add( session );
+ }
}
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
@@ -325,8 +327,10 @@ void ActiveMQConnection::removeSession(
try {
- // Remove this session from the set of active sessions.
- this->config->activeSessions.remove( session );
+ synchronized( &this->config->activeSessions ) {
+ // Remove this session from the set of active sessions.
+ this->config->activeSessions.remove( session );
+ }
}
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
@@ -422,22 +426,25 @@ void ActiveMQConnection::close() {
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
- // Get the complete list of active sessions.
- std::auto_ptr< Iterator<ActiveMQSession*> > iter( this->config->activeSessions.iterator() );
+ long long lastDeliveredSequenceId = 0;
- long long lastDeliveredSequenceId = 0;
+ synchronized( &this->config->activeSessions ) {
- // Dispose of all the Session resources we know are still open.
- while( iter->hasNext() ) {
- ActiveMQSession* session = iter->next();
- try{
- session->dispose();
+ // Get the complete list of active sessions.
+ std::auto_ptr< Iterator<ActiveMQSession*> > iter( this->config->activeSessions.iterator() );
- lastDeliveredSequenceId =
- Math::max( lastDeliveredSequenceId, session->getLastDeliveredSequenceId() );
- } catch( cms::CMSException& ex ){
- /* Absorb */
- }
+ // Dispose of all the Session resources we know are still open.
+ while( iter->hasNext() ) {
+ ActiveMQSession* session = iter->next();
+ try{
+ session->dispose();
+
+ lastDeliveredSequenceId =
+ Math::max( lastDeliveredSequenceId, session->getLastDeliveredSequenceId() );
+ } catch( cms::CMSException& ex ){
+ /* Absorb */
+ }
+ }
}
// Now inform the Broker we are shutting down.
@@ -456,17 +463,20 @@ void ActiveMQConnection::cleanup() {
try{
- // Get the complete list of active sessions.
- std::auto_ptr< Iterator<ActiveMQSession*> > iter( this->config->activeSessions.iterator() );
+ synchronized( &this->config->activeSessions ) {
- // Dispose of all the Session resources we know are still open.
- while( iter->hasNext() ) {
- ActiveMQSession* session = iter->next();
- try{
- session->dispose();
- } catch( cms::CMSException& ex ){
- /* Absorb */
- }
+ // Get the complete list of active sessions.
+ std::auto_ptr< Iterator<ActiveMQSession*> > iter( this->config->activeSessions.iterator() );
+
+ // Dispose of all the Session resources we know are still open.
+ while( iter->hasNext() ) {
+ ActiveMQSession* session = iter->next();
+ try{
+ session->dispose();
+ } catch( cms::CMSException& ex ){
+ /* Absorb */
+ }
+ }
}
if( this->config->isConnectionInfoSentToBroker ) {