activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r511083 - in /activemq/branches/activemq-4.1: ./ activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Date Fri, 23 Feb 2007 20:23:49 GMT
Author: chirino
Date: Fri Feb 23 12:23:49 2007
New Revision: 511083

URL: http://svn.apache.org/viewvc?view=rev&rev=511083
Log:
 r239@34:  chirino | 2007-02-23 14:48:46 -0500
 Sync oneway of a ShutdownInfo from the broker to the client could deadlock the vm transport.
 Sending that ShutdownInfo in the async dispatch thread now.
 
 

Modified:
    activemq/branches/activemq-4.1/   (props changed)
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java

Propchange: activemq/branches/activemq-4.1/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Fri Feb 23 12:23:49 2007
@@ -1 +1 @@
-635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:238
+635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:239

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?view=diff&rev=511083&r1=511082&r2=511083
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Fri Feb 23 12:23:49 2007
@@ -126,6 +126,7 @@
     protected final AtomicBoolean asyncException = new AtomicBoolean(false);
     private ConnectionContext context;
     private boolean networkConnection;
+    private CountDownLatch dispatchStopped = new CountDownLatch(1);
     
     static class ConnectionState extends org.apache.activemq.state.ConnectionState {
         private final ConnectionContext context;
@@ -793,7 +794,10 @@
                     sub.run();
                 }
             }
-        }else{
+        } else if( command.isShutdownInfo() ) {
+            dispatch(command);
+            dispatchStopped.countDown();
+        } else {
             dispatch(command);
         }
     }       
@@ -868,21 +872,19 @@
 	            if (masterBroker != null){
 	                masterBroker.stop();
 	            }
-	            
-	            // If the transport has not failed yet,
-	            // notify the peer that we are doing a normal shutdown.
-	            if( transportException == null ) {
-	            	transport.oneway(new ShutdownInfo());
-	            }
 	        } catch (Exception ignore) {
-	            //ignore.printStackTrace();
 	        }
 	
-	        transport.stop();
-	        active = false;
-	       
 	        if(disposed.compareAndSet(false, true)) {
 		        
+               // Clear out what's on the queue so that we can send the Shutdown command
quicker.
+               dispatchQueue.clear();
+               dispatchAsync(new ShutdownInfo());
+
+                // Wait up to 10 seconds for the shutdown command to be sent to 
+                // the client.
+                dispatchStopped.await(10, TimeUnit.SECONDS);
+
 		        if( taskRunner!=null )
 		            taskRunner.shutdown();
 		        
@@ -911,6 +913,8 @@
 				stopLatch.countDown();
 	        }
 	        
+	        transport.stop();
+	        active = false;
 	        
     		log.debug("Stopped connection: "+transport.getRemoteAddress());
     	}



Mime
View raw message