Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 14B6ED366 for ; Wed, 3 Oct 2012 14:46:52 +0000 (UTC) Received: (qmail 9744 invoked by uid 500); 3 Oct 2012 14:46:52 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 9711 invoked by uid 500); 3 Oct 2012 14:46:52 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 9704 invoked by uid 99); 3 Oct 2012 14:46:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 14:46:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 14:46:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 43E092388A29 for ; Wed, 3 Oct 2012 14:46:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1393515 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp Date: Wed, 03 Oct 2012 14:46:06 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121003144606.43E092388A29@eris.apache.org> Author: tabish Date: Wed Oct 3 14:46:05 2012 New Revision: 1393515 URL: http://svn.apache.org/viewvc?rev=1393515&view=rev Log: Protect the sessions list during close from concurrent access. 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=1393515&r1=1393514&r2=1393515&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 Wed Oct 3 14:46:05 2012 @@ -591,6 +591,7 @@ void ActiveMQConnection::close() { } // Get the complete list of active sessions. + this->config->sessionsLock.writeLock().lock(); std::auto_ptr< Iterator > > iter(this->config->activeSessions.iterator()); long long lastDeliveredSequenceId = 0; @@ -601,9 +602,10 @@ void ActiveMQConnection::close() { try { session->dispose(); lastDeliveredSequenceId = Math::max(lastDeliveredSequenceId, session->getLastDeliveredSequenceId()); - } catch( cms::CMSException& ex ){ + } catch (cms::CMSException& ex) { } } + this->config->sessionsLock.writeLock().unlock(); // As TemporaryQueue and TemporaryTopic instances are bound to a connection // we should just delete them after the connection is closed to free up memory