When sending directly, do it outside the valve lock to avoid a deadlock

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@649708 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-04-18 22:06:04 +00:00
parent 0c8afd13fb
commit e4ee0b2440
1 changed files with 10 additions and 5 deletions

View File

@ -77,6 +77,8 @@ public class VMTransport implements Transport, Task {
throw new IOException("Peer not connected.");
}
TransportListener transportListener=null;
try {
// Disable the peer from changing his state while we try to enqueue onto him.
peer.enqueueValve.increment();
@ -90,11 +92,7 @@ public class VMTransport implements Transport, Task {
peer.getMessageQueue().put(command);
peer.wakeup();
} else {
if( command == DISCONNECT ) {
peer.transportListener.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
} else {
peer.transportListener.onCommand(command);
}
transportListener = peer.transportListener;
}
enqueueValve.decrement();
} else {
@ -108,6 +106,13 @@ public class VMTransport implements Transport, Task {
peer.enqueueValve.decrement();
}
if( transportListener!=null ) {
if( command == DISCONNECT ) {
transportListener.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
} else {
transportListener.onCommand(command);
}
}
}
public void start() throws Exception {