* 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:
zzz
2010-12-12 14:49:30 +00:00
parent d4b0bfda7e
commit 7c63866c51
10 changed files with 66 additions and 21 deletions

View File

@ -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
@ -645,7 +652,6 @@ public class PeerCoordinator implements PeerListener
}
return piece.getId();
}
}
/**
* Maps file priorities to piece priorities.

View File

@ -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;
}

View File

@ -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>");
}
}
}

View File

@ -277,16 +277,20 @@ msgid "Downloaded"
msgstr "heruntergeladen"
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:295
# NOTE: purposely left blank to leave more room in the table header
#msgstr "heruntergeladen"
msgid "RX"
msgstr "heruntergeladen"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:298
msgid "Uploaded"
msgstr "hochgeladen"
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:300
# NOTE: purposely left blank to leave more room in the table header
#msgstr "hochgeladen"
msgid "TX"
msgstr "hochgeladen"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:303
msgid "Down Rate"
@ -294,8 +298,10 @@ msgstr "eingehend"
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:305
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:310
# NOTE: purposely left blank to leave more room in the table header
#msgstr "Übertragung"
msgid "Rate"
msgstr "Übertragung"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:308
msgid "Up Rate"

View File

@ -269,8 +269,10 @@ msgstr "tiempo restante de descarga"
#. space here would look better but nbsp is too big and thinsp breaks
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:290
# NOTE: purposely left blank to leave more room in the table header
#msgstr "Completado&nbsp;en"
msgid "ETA"
msgstr "Completado&nbsp;en"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:293
msgid "Downloaded"
@ -294,8 +296,10 @@ msgstr "Tasa&nbsp;de descarga"
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:305
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:310
# NOTE: purposely left blank to leave more room in the table header
#msgstr "Tasa&nbsp;de transferencia"
msgid "Rate"
msgstr "Tasa&nbsp;de transferencia"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:308
msgid "Up Rate"

View File

@ -268,8 +268,10 @@ msgid "Estimated Download Time"
msgstr "Temps estimé de téléchargement"
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:278
# NOTE: purposely left blank to leave more room in the table header
#msgstr "Temps&nbsp;restant"
msgid "ETA"
msgstr "Temps&nbsp;restant"
msgstr " "
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:281
msgid "Downloaded"

View File

@ -1,3 +1,10 @@
2010-12-12 zzz
* i2psnark:
- Fix end-game deadlock
- Fix last-modified check for multifile torrents, causing
apparent loss of data after abnormal exit
- Tweaks
2010-12-11 zzz
* Build: Fix 'ant distclean poupdate' again
* I2CP: Change a log error to a warning (ticket #353)

View File

@ -361,6 +361,14 @@ td:first-child {
color: #dd7 !important;
}
.choked {
color: #f00000 !important;
}
.unchoked {
color: #00f000 !important;
}
.thumb {
max-height: 64px;
max-width: 96px;

View File

@ -365,6 +365,14 @@ td:first-child {
color: #505 !important;
}
.choked {
color: #a00000 !important;
}
.unchoked {
color: #008000 !important;
}
.thumb {
max-height: 64px;
max-width: 96px;

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 36;
public final static long BUILD = 37;
/** for example "-test" */
public final static String EXTRA = "-rc";