https://issues.apache.org/jira/browse/AMQ-3684 - Potential deadlock in vm transport setListener when sender is blocked pending space

Deal with the case of blocked producer

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1236664 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-01-27 12:53:09 +00:00
parent dcf1f5e0cc
commit e901d2fd2e
1 changed files with 12 additions and 4 deletions

View File

@ -226,6 +226,13 @@ public class VMTransport implements Transport, Task {
public void setTransportListener(TransportListener commandListener) {
try {
// enqueue can block on blocking queue, preventing turnOff
// so avoid in that case: https://issues.apache.org/jira/browse/AMQ-3684
if (async && getMessageQueue().remainingCapacity() == 0) {
// enqueue blocked or will be
this.transportListener = commandListener;
wakeup();
} else {
try {
enqueueValve.turnOff();
this.transportListener = commandListener;
@ -233,6 +240,7 @@ public class VMTransport implements Transport, Task {
} finally {
enqueueValve.turnOn();
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}