ARTEMIS-217 fixing dead lock

https://issues.apache.org/jira/browse/ARTEMIS-217 fixing dead lock

This is using a separate lock for notifications, this way we won't hold a lock while communicating on netty which was the issue here.
This commit is contained in:
Clebert Suconic 2015-09-03 09:29:15 -04:00
parent ab618d295d
commit 220e39ef1f
1 changed files with 5 additions and 4 deletions

View File

@ -816,7 +816,9 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
} while (retry);
}
synchronized (topologyArrayGuard) {
// We always wait for the topology, as the server
// will send a single element if not cluster
// so clients can know the id of the server they are connected to
@ -824,7 +826,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
while (!isClosed() && !receivedTopology && timeout > System.currentTimeMillis()) {
// Now wait for the topology
try {
wait(1000);
topologyArrayGuard.wait(1000);
}
catch (InterruptedException e) {
throw new ActiveMQInterruptedException(e);
@ -847,7 +849,6 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return factory;
}
}
public boolean isHA() {
@ -1410,10 +1411,10 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
updateArraysAndPairs();
if (last) {
synchronized (this) {
synchronized (topologyArrayGuard) {
receivedTopology = true;
// Notify if waiting on getting topology
notifyAll();
topologyArrayGuard.notifyAll();
}
}
}