ARTEMIS-456 Synchronize sendReplicatePacket method

There is a potential deadlock scenario if 2 threads try
sendReplicatePacket.  Thread 1 registers Netty callback which will
invoke readyForWrites() method, which locks the callback list and waits
on the replicationLock.  Thread 2 enters sendReplicatePacket and gets
the replicationLock and is blocked on the callback list lock.  This fix
ensures the sendReplicatePacket blocks on the ReplicationManager meaning
no interleaving of the Netty callback thread and the wait on lock can
happen.
This commit is contained in:
Martyn Taylor 2016-03-23 15:33:49 +00:00 committed by jbertram
parent 0030918fef
commit afdb78dd5c
1 changed files with 1 additions and 1 deletions

View File

@ -330,7 +330,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene
return sendReplicatePacket(packet, true);
}
private OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) {
private synchronized OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) {
if (!enabled)
return null;
boolean runItNow = false;