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,12 +226,20 @@ public class VMTransport implements Transport, Task {
public void setTransportListener(TransportListener commandListener) {
try {
try {
enqueueValve.turnOff();
// 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();
} finally {
enqueueValve.turnOn();
} else {
try {
enqueueValve.turnOff();
this.transportListener = commandListener;
wakeup();
} finally {
enqueueValve.turnOn();
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);