activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r885586 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
Date Mon, 30 Nov 2009 21:31:14 GMT
Author: tabish
Date: Mon Nov 30 21:31:14 2009
New Revision: 885586

URL: http://svn.apache.org/viewvc?rev=885586&view=rev
Log:
Fix a potential memory leak when IndividualAck is used.

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?rev=885586&r1=885585&r2=885586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp Mon
Nov 30 21:31:14 2009
@@ -299,6 +299,19 @@
             // Stop and Wakeup all sync consumers.
             unconsumedMessages.close();
 
+            if( this->session->isIndividualAcknowledge() ) {
+                // For IndividualAck Mode we need to unlink the ack handler to remove a
+                // cyclic reference to the MessageDispatch that brought the message to us.
+                synchronized( &dispatchedMessages ) {
+                    std::auto_ptr< Iterator< Pointer<MessageDispatch> > >
iter( this->dispatchedMessages.iterator() );
+                    while( iter->hasNext() ) {
+                        iter->next()->getMessage()->setAckHandler( Pointer<ActiveMQAckHandler>()
);
+                    }
+
+                    dispatchedMessages.clear();
+                }
+            }
+
             // Remove this Consumer from the Connections set of Dispatchers
             this->session->disposeOf( this->consumerInfo->getConsumerId(), lastDeliveredSequenceId
);
 



Mime
View raw message