activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1419829 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: activemq/cmsutil/PooledSession.cpp activemq/cmsutil/SessionPool.cpp activemq/core/ActiveMQConnection.cpp decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
Date Mon, 10 Dec 2012 22:05:44 GMT
Author: tabish
Date: Mon Dec 10 22:05:43 2012
New Revision: 1419829

URL: http://svn.apache.org/viewvc?rev=1419829&view=rev
Log:
Fix some memory that can occur when exceptions are thrown.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp?rev=1419829&r1=1419828&r2=1419829&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp Mon
Dec 10 22:05:43 2012
@@ -50,13 +50,17 @@ PooledSession::~PooledSession() {
     // Destroy cached producers.
     std::auto_ptr<Iterator<CachedProducer*> > producers(producerCache.values().iterator());
     while (producers->hasNext()) {
-        delete producers->next();
+        try {
+            delete producers->next();
+        } catch (...) {}
     }
 
     // Destroy cached consumers.
     std::auto_ptr<Iterator<CachedConsumer*> > consumers(consumerCache.values().iterator());
     while (consumers->hasNext()) {
-        delete consumers->next();
+        try {
+            delete consumers->next();
+        } catch (...) {}
     }
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp?rev=1419829&r1=1419828&r2=1419829&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp Mon
Dec 10 22:05:43 2012
@@ -40,7 +40,9 @@ SessionPool::~SessionPool() {
         // Destroy all of the pooled session objects.
         list<PooledSession*>::iterator iter = sessions.begin();
         for (; iter != sessions.end(); ++iter) {
-            delete *iter;
+            try {
+                delete *iter;
+            } catch (...) {}
         }
 
         sessions.clear();

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=1419829&r1=1419828&r2=1419829&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
Mon Dec 10 22:05:43 2012
@@ -342,7 +342,7 @@ namespace core{
 
         ActiveMQConnection* connection;
         ConnectionConfig* config;
-        Exception* ex;
+        Pointer<Exception> ex;
 
     private:
 
@@ -357,8 +357,13 @@ namespace core{
 
         virtual void run() {
             try {
+
+                // Take control of this pointer, it will be given to the Connection who
+                // will destroy it when it closes.
+                Exception* error = ex.release();
+
                 // Mark this Connection as having a Failed transport.
-                this->connection->setFirstFailureError(ex);
+                this->connection->setFirstFailureError(error);
 
                 Pointer<Transport> transport = this->config->transport;
                 if (transport != NULL) {
@@ -378,7 +383,7 @@ namespace core{
 
                     while (iter->hasNext()) {
                         try{
-                            iter->next()->onException(ex);
+                            iter->next()->onException(error);
                         } catch(...) {}
                     }
                 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp?rev=1419829&r1=1419828&r2=1419829&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
Mon Dec 10 22:05:43 2012
@@ -512,8 +512,9 @@ namespace {
 
         Sync* sync;
 
-        ReadLock(Sync* sync) : Lock(), sync(sync) {
-        }
+        ReadLock(Sync* sync) : Lock(), sync(sync) {}
+
+        virtual ~ReadLock() {}
 
         /**
          * Acquires the read lock.
@@ -689,8 +690,9 @@ namespace {
 
         Sync* sync;
 
-        WriteLock(Sync* sync) : Lock(), sync(sync) {
-        }
+        WriteLock(Sync* sync) : Lock(), sync(sync) {}
+
+        virtual ~WriteLock() {}
 
         /**
          * Acquires the write lock.



Mime
View raw message