forked from I2P_Developers/i2p.i2p
* i2psnark: Fix request tracking bug preventing piece requests
This commit is contained in:
@ -215,7 +215,7 @@ class PeerCoordinator implements PeerListener
|
|||||||
|
|
||||||
public Storage getStorage() { return storage; }
|
public Storage getStorage() { return storage; }
|
||||||
|
|
||||||
// for web page detailed stats
|
/** for web page detailed stats */
|
||||||
public List<Peer> peerList()
|
public List<Peer> peerList()
|
||||||
{
|
{
|
||||||
return new ArrayList(peers);
|
return new ArrayList(peers);
|
||||||
@ -446,6 +446,12 @@ class PeerCoordinator implements PeerListener
|
|||||||
synchronized (downloaded_old) {
|
synchronized (downloaded_old) {
|
||||||
Arrays.fill(downloaded_old, 0);
|
Arrays.fill(downloaded_old, 0);
|
||||||
}
|
}
|
||||||
|
// failsafe
|
||||||
|
synchronized(wantedPieces) {
|
||||||
|
for (Piece pc : wantedPieces) {
|
||||||
|
pc.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
timer.schedule((CHECK_PERIOD / 2) + _random.nextInt((int) CHECK_PERIOD));
|
timer.schedule((CHECK_PERIOD / 2) + _random.nextInt((int) CHECK_PERIOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,8 +756,12 @@ class PeerCoordinator implements PeerListener
|
|||||||
// AND if there are almost no wanted pieces left (real end game).
|
// AND if there are almost no wanted pieces left (real end game).
|
||||||
// If we do end game all the time, we generate lots of extra traffic
|
// If we do end game all the time, we generate lots of extra traffic
|
||||||
// when the seeder is super-slow and all the peers are "caught up"
|
// when the seeder is super-slow and all the peers are "caught up"
|
||||||
if (wantedSize > END_GAME_THRESHOLD)
|
if (wantedSize > END_GAME_THRESHOLD) {
|
||||||
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
_log.info("Nothing to request, " + requested.size() + " being requested and " +
|
||||||
|
wantedSize + " still wanted");
|
||||||
return null; // nothing to request and not in end game
|
return null; // nothing to request and not in end game
|
||||||
|
}
|
||||||
// let's not all get on the same piece
|
// let's not all get on the same piece
|
||||||
// Even better would be to sort by number of requests
|
// Even better would be to sort by number of requests
|
||||||
if (record)
|
if (record)
|
||||||
@ -1078,10 +1088,11 @@ class PeerCoordinator implements PeerListener
|
|||||||
/** Called when a peer is removed, to prevent it from being used in
|
/** Called when a peer is removed, to prevent it from being used in
|
||||||
* rarest-first calculations.
|
* rarest-first calculations.
|
||||||
*/
|
*/
|
||||||
public void removePeerFromPieces(Peer peer) {
|
private void removePeerFromPieces(Peer peer) {
|
||||||
synchronized(wantedPieces) {
|
synchronized(wantedPieces) {
|
||||||
for (Piece piece : wantedPieces) {
|
for (Piece piece : wantedPieces) {
|
||||||
piece.removePeer(peer);
|
piece.removePeer(peer);
|
||||||
|
piece.setRequested(peer, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,6 +682,7 @@ class PeerState implements DataLoader
|
|||||||
_log.debug(peer + " addRequest() we are choked, delaying requestNextPiece()");
|
_log.debug(peer + " addRequest() we are choked, delaying requestNextPiece()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// huh? rv unused
|
||||||
more_pieces = requestNextPiece();
|
more_pieces = requestNextPiece();
|
||||||
} else if (more_pieces) // We want something
|
} else if (more_pieces) // We want something
|
||||||
{
|
{
|
||||||
@ -711,6 +712,8 @@ class PeerState implements DataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
// failsafe
|
// failsafe
|
||||||
|
// However this is bad as it thrashes the peer when we change our mind
|
||||||
|
// Ticket 691 cause here?
|
||||||
if (interesting && lastRequest == null && outstandingRequests.isEmpty())
|
if (interesting && lastRequest == null && outstandingRequests.isEmpty())
|
||||||
setInteresting(false);
|
setInteresting(false);
|
||||||
|
|
||||||
@ -784,6 +787,8 @@ class PeerState implements DataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
// failsafe
|
// failsafe
|
||||||
|
// However this is bad as it thrashes the peer when we change our mind
|
||||||
|
// Ticket 691 cause here?
|
||||||
if (outstandingRequests.isEmpty())
|
if (outstandingRequests.isEmpty())
|
||||||
lastRequest = null;
|
lastRequest = null;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class Piece implements Comparable {
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final Set<PeerID> peers;
|
private final Set<PeerID> peers;
|
||||||
/** @since 0.8.3 */
|
/** @since 0.8.3 */
|
||||||
private Set<PeerID> requests;
|
private volatile Set<PeerID> requests;
|
||||||
/** @since 0.8.1 */
|
/** @since 0.8.1 */
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
@ -54,7 +54,10 @@ class Piece implements Comparable {
|
|||||||
/** caller must synchronize */
|
/** caller must synchronize */
|
||||||
public boolean addPeer(Peer peer) { return this.peers.add(peer.getPeerID()); }
|
public boolean addPeer(Peer peer) { return this.peers.add(peer.getPeerID()); }
|
||||||
|
|
||||||
/** caller must synchronize */
|
/**
|
||||||
|
* Caller must synchronize.
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
public boolean removePeer(Peer peer) { return this.peers.remove(peer.getPeerID()); }
|
public boolean removePeer(Peer peer) { return this.peers.remove(peer.getPeerID()); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,6 +108,17 @@ class Piece implements Comparable {
|
|||||||
return this.requests == null ? 0 : this.requests.size();
|
return this.requests == null ? 0 : this.requests.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all knowledge of peers
|
||||||
|
* Caller must synchronize
|
||||||
|
* @since 0.9.3
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
peers.clear();
|
||||||
|
if (requests != null)
|
||||||
|
requests.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/** @return default 0 @since 0.8.1 */
|
/** @return default 0 @since 0.8.1 */
|
||||||
public int getPriority() { return this.priority; }
|
public int getPriority() { return this.priority; }
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2012-10-14 zzz
|
||||||
|
* Console: Use non-nio connector for Java 5 and JamVM/gij
|
||||||
|
(tickets #715 and #743)
|
||||||
|
* i2psnark: Fix request tracking bug preventing piece requests
|
||||||
|
|
||||||
2012-10-11 kytv
|
2012-10-11 kytv
|
||||||
* Italian translation updates from Transifex
|
* Italian translation updates from Transifex
|
||||||
* i2prouter:
|
* i2prouter:
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 14;
|
public final static long BUILD = 15;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user