i2psnark: Increase max piece size to 16 MB, max files to 999,

close files faster based on file count (tickets #1626, #1671)
Remove dup synchs
This commit is contained in:
zzz
2015-10-10 14:02:48 +00:00
parent 7063609f05
commit dd4d12f287
5 changed files with 42 additions and 15 deletions

View File

@ -267,7 +267,23 @@ class PeerCheckerTask implements Runnable
// close out unused files, but we don't need to do it every time
Storage storage = coordinator.getStorage();
if (storage != null && (_runCount % 4) == 0) {
if (storage != null) {
// The more files a torrent has, the more often we call the cleaner,
// to keep from running out of FDs
int files = storage.getFileCount();
int skip;
if (files == 1)
skip = 6;
else if (files <= 4)
skip = 4;
else if (files <= 20)
skip = 3;
else if (files <= 50)
skip = 2;
else
skip = 1;
if ((_runCount % skip) == 0)
storage.cleanRAFs();
}

View File

@ -1092,7 +1092,7 @@ public class SnarkManager implements CompleteListener {
}
/** hardcoded for sanity. perhaps this should be customizable, for people who increase their ulimit, etc. */
public static final int MAX_FILES_PER_TORRENT = 512;
public static final int MAX_FILES_PER_TORRENT = 999;
/**
* Set of canonical .torrent filenames that we are dealing with.

View File

@ -78,7 +78,7 @@ public class Storage implements Closeable
/** The default piece size. */
private static final int DEFAULT_PIECE_SIZE = 256*1024;
/** bigger than this will be rejected */
public static final int MAX_PIECE_SIZE = 8*1024*1024;
public static final int MAX_PIECE_SIZE = 16*1024*1024;
/** The maximum number of pieces in a torrent. */
public static final int MAX_PIECES = 10*1024;
public static final long MAX_TOTAL_SIZE = MAX_PIECE_SIZE * (long) MAX_PIECES;
@ -819,6 +819,14 @@ public class Storage implements Closeable
return rv;
}
/**
* Does not include directories.
* @since 0.9.23
*/
public int getFileCount() {
return _torrentFiles.size();
}
/**
* Includes the base for a multi-file torrent.
* Sorted bottom-up for easy deletion.
@ -958,11 +966,9 @@ public class Storage implements Closeable
pieceEnd += length;
while (fileEnd <= pieceEnd) {
TorrentFile tf = _torrentFiles.get(file);
synchronized(tf) {
try {
tf.closeRAF();
} catch (IOException ioe) {}
}
try {
tf.closeRAF();
} catch (IOException ioe) {}
if (++file >= _torrentFiles.size())
break;
fileEnd += _torrentFiles.get(file).length;
@ -1035,9 +1041,7 @@ public class Storage implements Closeable
for (TorrentFile tf : _torrentFiles)
{
try {
synchronized(tf) {
tf.closeRAF();
}
} catch (IOException ioe) {
_log.error("Error closing " + tf, ioe);
// gobble gobble
@ -1262,17 +1266,15 @@ public class Storage implements Closeable
return length;
}
private static final long RAFCloseDelay = 4*60*1000;
private static final long RAF_CLOSE_DELAY = 4*60*1000;
/**
* Close unused RAFs - call periodically
*/
public void cleanRAFs() {
long cutoff = System.currentTimeMillis() - RAFCloseDelay;
long cutoff = System.currentTimeMillis() - RAF_CLOSE_DELAY;
for (TorrentFile tf : _torrentFiles) {
synchronized(tf) {
tf.closeRAF(cutoff);
}
}
}

View File

@ -1,3 +1,9 @@
2015-10-10 zzz
* i2psnark: Increase max piece size to 16 MB, max files to 999,
close files faster based on file count (tickets #1626, #1671)
* JobQueue: Only adjust timing for negative clock shifts
* NamingServices: Add support for lookups prefixed with "www."
2015-10-08 zzz
* SimpleTimer2: Additional fix for uncaught IllegalStateException
affecting streaming timers (ticket #1672)
@ -30,6 +36,9 @@
2015-09-25 dg
* Rename _() for translation to _t() for Java 9 compatibility (ticket #1456)
2015-09-24 zzz
- Rename bad .torrent files instead of deleting them
2015-09-20 dg
* /configreseed: Add 'Reset URL list' button for revert to default hosts (ticket #1554, thanks dzirtt@gmail.com)

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 = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";