* i2psnark:
- Fix end-game deadlock - Fix last-modified check for multifile torrents, causing apparent loss of data after abnormal exit - UI Tweaks
This commit is contained in:
@ -566,12 +566,13 @@ public class PeerCoordinator implements PeerListener
|
||||
return -1;
|
||||
}
|
||||
|
||||
Piece piece = null;
|
||||
List<Piece> requested = new ArrayList();
|
||||
int wantedSize = END_GAME_THRESHOLD + 1;
|
||||
synchronized(wantedPieces)
|
||||
{
|
||||
Piece piece = null;
|
||||
if (record)
|
||||
Collections.sort(wantedPieces); // Sort in order of rarest first.
|
||||
List<Piece> requested = new ArrayList();
|
||||
Iterator<Piece> it = wantedPieces.iterator();
|
||||
while (piece == null && it.hasNext())
|
||||
{
|
||||
@ -588,13 +589,18 @@ public class PeerCoordinator implements PeerListener
|
||||
requested.add(p);
|
||||
}
|
||||
}
|
||||
if (piece == null)
|
||||
wantedSize = wantedPieces.size();
|
||||
} // synch
|
||||
|
||||
// Don't sync the following, deadlock from calling each Peer's isRequesting()
|
||||
|
||||
//Only request a piece we've requested before if there's no other choice.
|
||||
if (piece == null) {
|
||||
// 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
|
||||
// when the seeder is super-slow and all the peers are "caught up"
|
||||
if (wantedPieces.size() > END_GAME_THRESHOLD)
|
||||
if (wantedSize > END_GAME_THRESHOLD)
|
||||
return -1; // nothing to request and not in end game
|
||||
// let's not all get on the same piece
|
||||
// Even better would be to sort by number of requests
|
||||
@ -608,6 +614,7 @@ public class PeerCoordinator implements PeerListener
|
||||
// limit number of parallel requests
|
||||
int requestedCount = 0;
|
||||
for (Peer pr : peers) {
|
||||
// deadlock if synced on wantedPieces
|
||||
if (pr.isRequesting(p.getId())) {
|
||||
if (pr.equals(peer)) {
|
||||
// don't give it to him again
|
||||
@ -644,7 +651,6 @@ public class PeerCoordinator implements PeerListener
|
||||
piece.setRequested(true);
|
||||
}
|
||||
return piece.getId();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -514,7 +514,7 @@ public class Storage
|
||||
RAFfile[i] = f;
|
||||
total += lengths[i];
|
||||
if (useSavedBitField) {
|
||||
long lm = base.lastModified();
|
||||
long lm = f.lastModified();
|
||||
if (lm <= 0 || lm > savedTime)
|
||||
useSavedBitField = false;
|
||||
}
|
||||
|
@ -289,18 +289,21 @@ public class I2PSnarkServlet extends Default {
|
||||
out.write("<img border=\"0\" src=\"" + _imgPath + "eta.png\" alt=\"\" title=\"");
|
||||
out.write(_("Estimated time remaining"));
|
||||
out.write("\">");
|
||||
// Translators: Please keep short or translate as " "
|
||||
out.write(_("ETA"));
|
||||
}
|
||||
out.write("</th>\n<th align=\"right\">");
|
||||
out.write("<img border=\"0\" src=\"" + _imgPath + "head_rx.png\" alt=\"\" title=\"");
|
||||
out.write(_("Downloaded"));
|
||||
out.write("\">");
|
||||
// Translators: Please keep short or translate as " "
|
||||
out.write(_("RX"));
|
||||
out.write("</th>\n<th align=\"right\">");
|
||||
if (_manager.util().connected() && !snarks.isEmpty()) {
|
||||
out.write("<img border=\"0\" src=\"" + _imgPath + "head_tx.png\" alt=\"\" title=\"");
|
||||
out.write(_("Uploaded"));
|
||||
out.write("\">");
|
||||
// Translators: Please keep short or translate as " "
|
||||
out.write(_("TX"));
|
||||
}
|
||||
out.write("</th>\n<th align=\"right\">");
|
||||
@ -310,6 +313,7 @@ public class I2PSnarkServlet extends Default {
|
||||
out.write("\" alt=\"");
|
||||
out.write(_("RX"));
|
||||
out.write(" \">");
|
||||
// Translators: Please keep short or translate as " "
|
||||
out.write(_("Rate"));
|
||||
}
|
||||
out.write("</th>\n<th align=\"right\">");
|
||||
@ -1007,39 +1011,39 @@ public class I2PSnarkServlet extends Default {
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
if (remaining > 0) {
|
||||
if (peer.isInteresting() && !peer.isChoked()) {
|
||||
out.write("<font color=#00ff00>");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</font>");
|
||||
out.write("<span class=\"unchoked\">");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</span>");
|
||||
} else {
|
||||
out.write("<font color=#ff0000><a title=\"");
|
||||
out.write("<span class=\"choked\"><a title=\"");
|
||||
if (!peer.isInteresting())
|
||||
out.write(_("Uninteresting (The peer has no pieces we need)"));
|
||||
else
|
||||
out.write(_("Choked (The peer is not allowing us to request pieces)"));
|
||||
out.write("\">");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</a></font>");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</a></span>");
|
||||
}
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
if (pct != 100.0) {
|
||||
if (peer.isInterested() && !peer.isChoking()) {
|
||||
out.write("<font color=#00ff00>");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</font>");
|
||||
out.write("<span class=\"unchoked\">");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</span>");
|
||||
} else {
|
||||
out.write("<font color=#ff0000><a title=\"");
|
||||
out.write("<span class=\"choked\"><a title=\"");
|
||||
if (!peer.isInterested())
|
||||
out.write(_("Uninterested (We have no pieces the peer needs)"));
|
||||
else
|
||||
out.write(_("Choking (We are not allowing the peer to request pieces)"));
|
||||
out.write("\">");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</a></font>");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</a></span>");
|
||||
}
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("</td></tr>\n\t");
|
||||
if (showDebug)
|
||||
out.write("<tr><td></td><td colspan=\"10\" align=\"right\" class=\"" + rowClass + "\">" + peer.getSocket() + "</td></tr>");
|
||||
out.write("<tr class=\"" + rowClass + "\"><td></td><td colspan=\"10\" align=\"right\" class=\"" + rowClass + "\">" + peer.getSocket() + "</td></tr>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user