activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
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 GMT
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( )



Mime
View raw message