mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 06:44:16 +00:00
Missing synchronization for iterations.
(over synchronizedMap/synchronizedSet)
This commit is contained in:
parent
831f2d582f
commit
4d58ea5111
@ -304,7 +304,9 @@ public class PeerGroup {
|
||||
*/
|
||||
public synchronized List<Peer> getConnectedPeers() {
|
||||
ArrayList<Peer> result = new ArrayList<Peer>(peers.size());
|
||||
synchronized (peers) {
|
||||
result.addAll(peers);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -366,6 +368,7 @@ public class PeerGroup {
|
||||
FutureTask<Transaction> future = new FutureTask<Transaction>(new Runnable() {
|
||||
public void run() {
|
||||
// This is run with the peer group already locked.
|
||||
synchronized (peers) {
|
||||
for (Peer peer : peers) {
|
||||
try {
|
||||
log.info("{}: Sending transaction {}", peer.getAddress(), tx.getHashAsString());
|
||||
@ -375,6 +378,7 @@ public class PeerGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, tx);
|
||||
peerGroupThread.addTask(future);
|
||||
return future;
|
||||
@ -433,10 +437,8 @@ public class PeerGroup {
|
||||
* {@link PeerEventListener} and use the onPeerConnected/onPeerDisconnected methods.
|
||||
*/
|
||||
public synchronized int numConnectedPeers() {
|
||||
synchronized (peers) {
|
||||
return peers.size();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean isRunning() {
|
||||
return running;
|
||||
@ -500,9 +502,11 @@ public class PeerGroup {
|
||||
synchronized (PeerGroup.this) {
|
||||
running = false;
|
||||
shutdownPeerDiscovery();
|
||||
synchronized (channelFutures.values()) {
|
||||
for (ChannelFuture future : channelFutures.values()) {
|
||||
future.getChannel().close();
|
||||
}
|
||||
}
|
||||
bootstrap.releaseExternalResources();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user