3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 02:05:53 +00:00

Fix lock inversion.

This commit is contained in:
Mike Hearn 2012-12-24 23:33:13 +00:00
parent b71015a297
commit eb7c4be136

View File

@ -1098,8 +1098,11 @@ public class PeerGroup extends AbstractIdleService {
} }
/** Given a list of Peers, return a Peer to be used as the download peer. */ /** Given a list of Peers, return a Peer to be used as the download peer. */
protected Peer selectDownloadPeer(List<Peer> peers) { protected Peer selectDownloadPeer(List<Peer> origPeers) {
synchronized (peers) { List<Peer> peers;
synchronized (origPeers) {
peers = new ArrayList<Peer>(origPeers);
}
if (peers.isEmpty()) if (peers.isEmpty())
return null; return null;
// Make sure we don't select a peer that is behind/synchronizing itself. // Make sure we don't select a peer that is behind/synchronizing itself.
@ -1109,7 +1112,6 @@ public class PeerGroup extends AbstractIdleService {
} }
throw new IllegalStateException("Unreachable"); throw new IllegalStateException("Unreachable");
} }
}
private static class PeerGroupThreadFactory implements ThreadFactory { private static class PeerGroupThreadFactory implements ThreadFactory {
static final AtomicInteger poolNumber = new AtomicInteger(1); static final AtomicInteger poolNumber = new AtomicInteger(1);