Decrease DH refiller initial delay and increase buffer size

to reduce chance of running out on high-bandwidth routers
This commit is contained in:
zzz
2015-02-06 00:46:13 +00:00
parent 1234b6b148
commit 60f86f342b

View File

@ -62,9 +62,9 @@ public class DHSessionKeyBuilder {
private final static String PROP_DH_PRECALC_MIN = "crypto.dh.precalc.min";
private final static String PROP_DH_PRECALC_MAX = "crypto.dh.precalc.max";
private final static String PROP_DH_PRECALC_DELAY = "crypto.dh.precalc.delay";
private final static int DEFAULT_DH_PRECALC_MIN = 15;
private final static int DEFAULT_DH_PRECALC_MAX = 40;
private final static int DEFAULT_DH_PRECALC_DELAY = 200;
private final static int DEFAULT_DH_PRECALC_MIN = 20;
private final static int DEFAULT_DH_PRECALC_MAX = 60;
private final static int DEFAULT_DH_PRECALC_DELAY = 50;
/**
* Create a new public/private value pair for the DH exchange.
@ -429,6 +429,12 @@ public class DHSessionKeyBuilder {
public void returnUnused(DHSessionKeyBuilder builder);
}
/**
* Try to keep DH pairs at the ready.
* It's important to do this in a separate thread, because if we run out,
* the pairs are generated in the NTCP Pumper thread,
* and it can fall behind.
*/
public static class PrecalcRunner extends I2PThread implements Factory {
private final I2PAppContext _context;
private final Log _log;
@ -438,8 +444,8 @@ public class DHSessionKeyBuilder {
private final LinkedBlockingQueue<DHSessionKeyBuilder> _builders;
private volatile boolean _isRunning;
/** check every 30 seconds whether we have less than the minimum */
private long _checkDelay = 30 * 1000;
/** check periodically whether we have less than the minimum */
private long _checkDelay = 10 * 1000;
public PrecalcRunner(I2PAppContext ctx) {
super("DH Precalc");