You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/02/23 21:25:55 UTC
svn commit: r511091 - in /activemq/branches/activemq-4.1: ./
activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Author: chirino
Date: Fri Feb 23 12:25:54 2007
New Revision: 511091
URL: http://svn.apache.org/viewvc?view=rev&rev=511091
Log:
r247@34: chirino | 2007-02-23 14:50:04 -0500
Some more small changes to try to get connections to disconnect in time
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:25:54 2007
@@ -1 +1 @@
-635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:246
+635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:247
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=511091&r1=511090&r2=511091
==============================================================================
--- 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:25:54 2007
@@ -121,7 +121,8 @@
private boolean pendingStop;
private long timeStamp = 0;
- private AtomicBoolean stopped = new AtomicBoolean(false);
+ private final AtomicBoolean stopped = new AtomicBoolean(false);
+ private final AtomicBoolean transportDisposed = new AtomicBoolean();
protected final AtomicBoolean disposed=new AtomicBoolean(false);
private CountDownLatch stopLatch = new CountDownLatch(1);
protected final AtomicBoolean asyncException = new AtomicBoolean(false);
@@ -936,8 +937,12 @@
if( taskRunner!=null ) {
taskRunner.wakeup();
- dispatchStoppedLatch.await();
+ // Give it a change to stop gracefully.
+ dispatchStoppedLatch.await(5, TimeUnit.SECONDS);
+ disposeTransport();
taskRunner.shutdown();
+ } else {
+ disposeTransport();
}
// Run the MessageDispatch callbacks so that message references get cleaned up.
@@ -973,11 +978,6 @@
}
stopLatch.countDown();
}
-
- transport.stop();
- active = false;
-
- log.debug("Stopped connection: "+transport.getRemoteAddress());
}
}
@@ -1158,4 +1158,16 @@
return object.getInfo().getConnectionId().toString();
}
+
+ protected void disposeTransport() {
+ if( transportDisposed.compareAndSet(false, true) ) {
+ try {
+ transport.stop();
+ active = false;
+ log.debug("Stopped connection: "+transport.getRemoteAddress());
+ } catch (Exception e) {
+ log.debug("Could not stop transport: "+e,e);
+ }
+ }
+ }
}