From 8c9167464b51618eefd5bf4b3ce50ddf4af34e72 Mon Sep 17 00:00:00 2001 From: jrandom Date: Fri, 17 Feb 2006 09:07:53 +0000 Subject: [PATCH] 2006-02-17 jrandom * Disable the message history log file by default (duh - feel free to delete messageHistory.txt after upgrading. thanks deathfatty!) * Limit the size of the inbound tunnel build request queue so we don't get an insane backlog of requests that we're bound to reject, and adjust the queue processing so we keep on churning through them when we've got a backlog. * Small fixes for the multiuser syndie operation (thanks Complication!) * Renamed modified PRNG classes that were imported from gnu-crypto so we don't conflict with JVMs using that as a JCE provider (thanks blx!) --- .../{BasePRNG.java => BasePRNGStandalone.java} | 6 +++--- .../{Fortuna.java => FortunaStandalone.java} | 11 ++++++----- .../src/net/i2p/util/FortunaRandomSource.java | 6 +++--- history.txt | 13 ++++++++++++- .../java/src/net/i2p/router/MessageHistory.java | 2 +- .../java/src/net/i2p/router/RouterVersion.java | 4 ++-- .../i2p/router/tunnel/pool/BuildExecutor.java | 4 +++- .../i2p/router/tunnel/pool/BuildHandler.java | 17 ++++++++++++++++- 8 files changed, 46 insertions(+), 17 deletions(-) rename core/java/src/gnu/crypto/prng/{BasePRNG.java => BasePRNGStandalone.java} (97%) rename core/java/src/gnu/crypto/prng/{Fortuna.java => FortunaStandalone.java} (96%) diff --git a/core/java/src/gnu/crypto/prng/BasePRNG.java b/core/java/src/gnu/crypto/prng/BasePRNGStandalone.java similarity index 97% rename from core/java/src/gnu/crypto/prng/BasePRNG.java rename to core/java/src/gnu/crypto/prng/BasePRNGStandalone.java index c8840a61d..c52f5cae7 100644 --- a/core/java/src/gnu/crypto/prng/BasePRNG.java +++ b/core/java/src/gnu/crypto/prng/BasePRNGStandalone.java @@ -47,9 +47,9 @@ import java.util.Map; *

An abstract class to facilitate implementing PRNG algorithms.

* * Modified slightly by jrandom for I2P (removing unneeded exceptions) - * @version $Revision: 1.12 $ + * @version $Revision: 1.1 $ */ -public abstract class BasePRNG implements IRandom { +public abstract class BasePRNGStandalone implements IRandom { // Constants and variables // ------------------------------------------------------------------------- @@ -74,7 +74,7 @@ public abstract class BasePRNG implements IRandom { * * @param name the canonical name of this instance. */ - protected BasePRNG(String name) { + protected BasePRNGStandalone(String name) { super(); this.name = name; diff --git a/core/java/src/gnu/crypto/prng/Fortuna.java b/core/java/src/gnu/crypto/prng/FortunaStandalone.java similarity index 96% rename from core/java/src/gnu/crypto/prng/Fortuna.java rename to core/java/src/gnu/crypto/prng/FortunaStandalone.java index 0a48b4c48..7de39436d 100644 --- a/core/java/src/gnu/crypto/prng/Fortuna.java +++ b/core/java/src/gnu/crypto/prng/FortunaStandalone.java @@ -93,10 +93,11 @@ import net.i2p.crypto.CryptixAESKeyCache; * * Modified by jrandom for I2P to use Bouncycastle's SHA256, Cryptix's AES, * to strip out some unnecessary dependencies and increase the buffer size. + * Renamed from Fortuna to FortunaStandalone so it doesn't conflict with the + * gnu-crypto implementation, which has been imported into GNU/classpath * */ -public class Fortuna extends BasePRNG - implements Serializable, RandomEventListener +public class FortunaStandalone extends BasePRNGStandalone implements Serializable, RandomEventListener { private static final long serialVersionUID = 0xFACADE; @@ -113,7 +114,7 @@ public class Fortuna extends BasePRNG public static final String SEED = "gnu.crypto.prng.fortuna.seed"; - public Fortuna() + public FortunaStandalone() { super("Fortuna i2p"); generator = new Generator(); @@ -215,7 +216,7 @@ public class Fortuna extends BasePRNG * right; Fortuna itself is basically a wrapper around this generator * that manages reseeding in a secure way. */ - public static class Generator extends BasePRNG implements Cloneable + public static class Generator extends BasePRNGStandalone implements Cloneable { private static final int LIMIT = 1 << 20; @@ -341,7 +342,7 @@ public class Fortuna extends BasePRNG } public static void main(String args[]) { - Fortuna f = new Fortuna(); + FortunaStandalone f = new FortunaStandalone(); java.util.HashMap props = new java.util.HashMap(); byte initSeed[] = new byte[1234]; new java.util.Random().nextBytes(initSeed); diff --git a/core/java/src/net/i2p/util/FortunaRandomSource.java b/core/java/src/net/i2p/util/FortunaRandomSource.java index b86158a80..a470da3f0 100644 --- a/core/java/src/net/i2p/util/FortunaRandomSource.java +++ b/core/java/src/net/i2p/util/FortunaRandomSource.java @@ -14,7 +14,7 @@ import java.security.SecureRandom; import net.i2p.I2PAppContext; import net.i2p.crypto.EntropyHarvester; -import gnu.crypto.prng.Fortuna; +import gnu.crypto.prng.FortunaStandalone; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -26,13 +26,13 @@ import java.io.IOException; * */ public class FortunaRandomSource extends RandomSource implements EntropyHarvester { - private Fortuna _fortuna; + private FortunaStandalone _fortuna; private double _nextGaussian; private boolean _haveNextGaussian; public FortunaRandomSource(I2PAppContext context) { super(context); - _fortuna = new Fortuna(); + _fortuna = new FortunaStandalone(); byte seed[] = new byte[1024]; if (initSeed(seed)) { _fortuna.seed(seed); diff --git a/history.txt b/history.txt index 8d72e01e6..67499a57e 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,15 @@ -$Id: history.txt,v 1.401 2006/02/16 05:33:31 jrandom Exp $ +$Id: history.txt,v 1.402 2006/02/16 15:44:07 jrandom Exp $ + +2006-02-17 jrandom + * Disable the message history log file by default (duh - feel free to + delete messageHistory.txt after upgrading. thanks deathfatty!) + * Limit the size of the inbound tunnel build request queue so we don't + get an insane backlog of requests that we're bound to reject, and adjust + the queue processing so we keep on churning through them when we've got + a backlog. + * Small fixes for the multiuser syndie operation (thanks Complication!) + * Renamed modified PRNG classes that were imported from gnu-crypto so we + don't conflict with JVMs using that as a JCE provider (thanks blx!) * 2006-02-16 0.6.1.10 released diff --git a/router/java/src/net/i2p/router/MessageHistory.java b/router/java/src/net/i2p/router/MessageHistory.java index a48a94420..7ccc16b21 100644 --- a/router/java/src/net/i2p/router/MessageHistory.java +++ b/router/java/src/net/i2p/router/MessageHistory.java @@ -39,7 +39,7 @@ public class MessageHistory { /** config property determining whether we want to debug with the message history */ public final static String PROP_KEEP_MESSAGE_HISTORY = "router.keepHistory"; - public final static boolean DEFAULT_KEEP_MESSAGE_HISTORY = true; + public final static boolean DEFAULT_KEEP_MESSAGE_HISTORY = false; /** config property determining where we want to log the message history, if we're keeping one */ public final static String PROP_MESSAGE_HISTORY_FILENAME = "router.historyFilename"; public final static String DEFAULT_MESSAGE_HISTORY_FILENAME = "messageHistory.txt"; diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 3473cf47d..594dc0d8e 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.344 $ $Date: 2006/02/16 05:33:29 $"; + public final static String ID = "$Revision: 1.345 $ $Date: 2006/02/16 15:44:12 $"; public final static String VERSION = "0.6.1.10"; - public final static long BUILD = 0; + public final static long BUILD = 1; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java index 30c68005e..e3a62b2cb 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java @@ -199,7 +199,9 @@ class BuildExecutor implements Runnable { } } - _handler.handleInboundRequests(); + boolean pendingRemaining = _handler.handleInboundRequests(); + if (pendingRemaining) + _repoll = true; wanted.clear(); pools.clear(); diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java index 008598a9a..5515e5d15 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java @@ -57,9 +57,17 @@ class BuildHandler { } private static final int MAX_HANDLE_AT_ONCE = 5; + /** + * Don't keep too many messages on the queue - when it reaches this size, delete the oldest request + */ + private static final int MAX_QUEUED_REQUESTS = MAX_HANDLE_AT_ONCE * (BuildRequestor.REQUEST_TIMEOUT/1000); private static final int NEXT_HOP_LOOKUP_TIMEOUT = 5*1000; - void handleInboundRequests() { + /** + * Blocking call to handle a few of the pending inbound requests, returning true if + * there are remaining requeusts we skipped over + */ + boolean handleInboundRequests() { List handled = null; synchronized (_inboundBuildMessages) { int toHandle = _inboundBuildMessages.size(); @@ -101,6 +109,11 @@ class BuildHandler { handleRequestAsInboundEndpoint(state); } } + + // anything else? + synchronized (_inboundBuildMessages) { + return _inboundBuildMessages.size() > 0; + } } void handleInboundReplies() { @@ -503,6 +516,8 @@ class BuildHandler { _log.warn("Dropping the reply " + reqId + ", as we used to be building that"); } else { synchronized (_inboundBuildMessages) { + while (_inboundBuildMessages.size() > MAX_QUEUED_REQUESTS) + _inboundBuildMessages.remove(0); // keep the newest requests first, to offer better service _inboundBuildMessages.add(new BuildMessageState(receivedMessage, from, fromHash)); } _exec.repoll();