I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3816c791 authored by ragnarok's avatar ragnarok Committed by zzz
Browse files

Clean up some possible thread safety issues.

parent 8458e4e0
No related branches found
No related tags found
No related merge requests found
......@@ -511,11 +511,12 @@ public class PeerCoordinator implements PeerListener
{
// Unchoke some random other peer
unchokePeer();
// Don't count disconnected peers for the rarest-first calculations
for(Iterator iter = wantedPieces.iterator(); iter.hasNext(); ) {
Piece piece = (Piece)iter.next();
piece.removePeer(peer);
synchronized(wantedPieces) {
// Don't count disconnected peers for the rarest-first calculations
for(Iterator iter = wantedPieces.iterator(); iter.hasNext(); ) {
Piece piece = (Piece)iter.next();
piece.removePeer(peer);
}
}
}
}
......
......@@ -2,6 +2,7 @@ package org.klomp.snark;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
public class Piece implements Comparable {
......@@ -11,7 +12,7 @@ public class Piece implements Comparable {
public Piece(int id) {
this.id = id;
this.peers = new HashSet();
this.peers = Collections.synchronizedSet(new HashSet());
this.requested = false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment