activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r501860 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core: ActiveMQSession.cpp ActiveMQSession.h
Date Wed, 31 Jan 2007 15:16:36 GMT
Author: tabish
Date: Wed Jan 31 07:16:35 2007
New Revision: 501860

URL: http://svn.apache.org/viewvc?view=rev&rev=501860
Log:
http://issues.apache.org/activemq/browse/AMQCPP-63

Fixed a potential memory leak in the Session.

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?view=diff&rev=501860&r1=501859&r2=501860
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
Wed Jan 31 07:16:35 2007
@@ -124,6 +124,9 @@
         
         // Stop the Async Thread if its running
         stopThread();
+
+        // Remove any unsent cloned messages.
+        purgeMessages();
     }
     AMQ_CATCH_NOTHROW( ActiveMQException )
     AMQ_CATCHALL_NOTHROW( )
@@ -743,6 +746,26 @@
             asyncThread = NULL;
         }
     }        
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQSession::purgeMessages() throw ( ActiveMQException )
+{
+    try
+    {
+        synchronized( &msgQueue )
+        {
+            while( !msgQueue.empty() )
+            {
+                // destroy these messages if this is not a transacted
+                // session, if it is then the tranasction will clean 
+                // the messages up.
+                delete msgQueue.pop().first;
+            }
+        }
+    }
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )
 }

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h?view=diff&rev=501860&r1=501859&r2=501860
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
Wed Jan 31 07:16:35 2007
@@ -331,12 +331,18 @@
          * is invoked, which means that the caller is choosing to use this
          * consumer asynchronously instead of synchronously (receive).
          */
-        void startThread() throw (exceptions::ActiveMQException);
+        void startThread() throw ( exceptions::ActiveMQException );
         
         /**
          * Stops the asynchronous message processing thread if it's started.
          */
-        void stopThread() throw (exceptions::ActiveMQException);
+        void stopThread() throw ( exceptions::ActiveMQException );
+
+        /**
+         * Purges all messages currently in the queue.  This can be as a
+         * result of a rollback, or of the consumer being shutdown.
+         */
+        virtual void purgeMessages() throw ( exceptions::ActiveMQException );
 
     };
 



Mime
View raw message