ARTEMIS-982 Fixing possible deadlock on AMQP.close & delivery

https://issues.apache.org/jira/browse/ARTEMIS-982

This is fixing a possible deadlock on delivering messages while AMQP close is called for any reason.
This commit is contained in:
Clebert Suconic 2017-02-17 16:29:18 -05:00 committed by Justin Bertram
parent 51aa18a186
commit b788acd834
2 changed files with 10 additions and 8 deletions

View File

@ -335,11 +335,13 @@ public class AMQPConnectionContext extends ProtonInitializable {
synchronized (getLock()) {
connection.close();
connection.free();
for (AMQPSessionContext protonSession : sessions.values()) {
protonSession.close();
}
sessions.clear();
}
for (AMQPSessionContext protonSession : sessions.values()) {
protonSession.close();
}
sessions.clear();
// We must force write the channel before we actually destroy the connection
onTransport(handler.getTransport());
destroy();

View File

@ -16,10 +16,10 @@
*/
package org.apache.activemq.artemis.protocol.amqp.proton;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
import org.apache.activemq.artemis.protocol.amqp.client.ProtonClientSenderContext;
@ -44,9 +44,9 @@ public class AMQPSessionContext extends ProtonInitializable {
private long currentTag = 0;
protected Map<Receiver, ProtonServerReceiverContext> receivers = new HashMap<>();
protected Map<Receiver, ProtonServerReceiverContext> receivers = new ConcurrentHashMap<>();
protected Map<Sender, ProtonServerSenderContext> senders = new HashMap<>();
protected Map<Sender, ProtonServerSenderContext> senders = new ConcurrentHashMap<>();
protected boolean closed = false;
@ -56,7 +56,7 @@ public class AMQPSessionContext extends ProtonInitializable {
this.session = session;
}
protected Map<Object, ProtonServerSenderContext> serverSenders = new HashMap<>();
protected Map<Object, ProtonServerSenderContext> serverSenders = new ConcurrentHashMap<>();
@Override
public void initialise() throws Exception {