mirror of https://github.com/apache/activemq.git
Only unlock a service lock if we managed to lock it
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@637454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d28bbfdab
commit
1987cfa234
|
@ -889,10 +889,11 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
|
|||
new Thread("ActiveMQ Transport Stopper: "+ transport.getRemoteAddress()) {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean locked = false;
|
||||
// make sure we are not servicing client requests while we are shutting down.
|
||||
try {
|
||||
//we could be waiting a long time if the network has gone - so only wait 1 second
|
||||
serviceLock.writeLock().tryLock(1,TimeUnit.SECONDS);
|
||||
locked = serviceLock.writeLock().tryLock(1,TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.debug("Try get writeLock interrupted ",e);
|
||||
}
|
||||
|
@ -903,9 +904,11 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
|
|||
LOG.debug("Error occured while shutting down a connection to '" + transport.getRemoteAddress()+ "': ", e);
|
||||
} finally {
|
||||
stopped.countDown();
|
||||
if (locked) {
|
||||
serviceLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue