Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 94725 invoked from network); 24 Jan 2007 17:03:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jan 2007 17:03:06 -0000 Received: (qmail 86277 invoked by uid 500); 24 Jan 2007 17:03:12 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 86261 invoked by uid 500); 24 Jan 2007 17:03:12 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 86252 invoked by uid 99); 24 Jan 2007 17:03:12 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jan 2007 09:03:12 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id A72B21A981A; Wed, 24 Jan 2007 09:01:28 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r499480 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core: ActiveMQConsumer.cpp ActiveMQSession.cpp Date: Wed, 24 Jan 2007 17:01:28 -0000 To: activemq-commits@geronimo.apache.org From: nmittler@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070124170128.A72B21A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nmittler Date: Wed Jan 24 09:01:27 2007 New Revision: 499480 URL: http://svn.apache.org/viewvc?view=rev&rev=499480 Log: [AMQCPP-46] - a few more clean-up items Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?view=diff&rev=499480&r1=499479&r2=499480 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp Wed Jan 24 09:01:27 2007 @@ -150,17 +150,17 @@ { // Check for empty in case of spurious wakeup, or race to // queue lock. - while( !shutdown && msgQueue.empty() ) + while( !shutdown && !closed && msgQueue.empty() ) { msgQueue.wait(); } // This will only happen when this object is being - // destroyed in another thread context - kind of + // closed in another thread context - kind of // scary. - if( shutdown ){ + if( shutdown || closed ){ throw ActiveMQException( __FILE__, __LINE__, - "Consumer is being destroyed in another thread" ); + "Consumer is being closed in another thread" ); } // Fetch the Message then copy it so it can be handed off @@ -199,7 +199,8 @@ synchronized( &msgQueue ) { // Check for empty, and wait if its not - if( msgQueue.empty() ){ + if( !shutdown && !closed && msgQueue.empty() ){ + msgQueue.wait(millisecs); // if its still empty...bail @@ -207,6 +208,14 @@ return NULL; } } + + // This will only happen when this object is being + // closed in another thread context - kind of + // scary. + if( shutdown || closed ){ + throw ActiveMQException( __FILE__, __LINE__, + "Consumer is being closed in another thread" ); + } // Fetch the Message then copy it so it can be handed off // to the user. @@ -234,7 +243,7 @@ { try { - if( closed ) + if( shutdown || closed ) { throw InvalidStateException( __FILE__, __LINE__, 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=499480&r1=499479&r2=499480 ============================================================================== --- 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 24 09:01:27 2007 @@ -75,13 +75,16 @@ //////////////////////////////////////////////////////////////////////////////// void ActiveMQSession::close(void) throw ( cms::CMSException ) { - if(closed) - { + // If we're already close, just get outta' here. + if( closed ) { return; } try { + // Mark as done. + closed = true; + // Destroy the Transaction if( transaction != NULL ){ delete transaction; @@ -91,9 +94,7 @@ // Destroy this sessions resources connection->getConnectionData()-> getConnector()->destroyResource( sessionInfo ); - - // mark as done - closed = true; + sessionInfo = NULL; } AMQ_CATCH_NOTHROW( ActiveMQException ) AMQ_CATCHALL_NOTHROW( )