From 99ebad3032ccca81c25592f3796a8de40b6c5dce Mon Sep 17 00:00:00 2001 From: sponge Date: Wed, 9 Feb 2011 16:15:36 +0000 Subject: [PATCH] BOB config fix, I2CP fix some leaks, see history.txt for details --- apps/BOB/src/net/i2p/BOB/BOB.java | 18 +++++++++++++++--- .../net/i2p/data/i2cp/I2CPMessageReader.java | 3 +++ .../i2p/internal/QueuedI2CPMessageReader.java | 8 +++++++- history.txt | 7 +++++++ .../client/QueuedClientConnectionRunner.java | 3 ++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apps/BOB/src/net/i2p/BOB/BOB.java b/apps/BOB/src/net/i2p/BOB/BOB.java index 2c689f65d..60bf2b9ff 100644 --- a/apps/BOB/src/net/i2p/BOB/BOB.java +++ b/apps/BOB/src/net/i2p/BOB/BOB.java @@ -120,6 +120,7 @@ public class BOB { public final static String PROP_CONFIG_LOCATION = "BOB.config"; public final static String PROP_BOB_PORT = "BOB.port"; public final static String PROP_BOB_HOST = "BOB.host"; + public final static String PROP_CFG_VER = "BOB.CFG.VER"; private static NamedDB database; private static Properties props = new Properties(); private static AtomicBoolean spin = new AtomicBoolean(true); @@ -209,30 +210,41 @@ public class BOB { // Global router and client API configurations that are missing are set to defaults here. if (!props.containsKey(I2PClient.PROP_TCP_HOST)) { props.setProperty(I2PClient.PROP_TCP_HOST, "localhost"); + save = true; } if (!props.containsKey(I2PClient.PROP_TCP_PORT)) { props.setProperty(I2PClient.PROP_TCP_PORT, "7654"); - } - if (!props.containsKey(I2PClient.PROP_RELIABILITY)) { - props.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT); + save = true; } if (!props.containsKey(PROP_BOB_PORT)) { props.setProperty(PROP_BOB_PORT, "2827"); // 0xB0B + save = true; } if (!props.containsKey("inbound.length")) { props.setProperty("inbound.length", "1"); + save = true; } if (!props.containsKey("outbound.length")) { props.setProperty("outbound.length", "1"); + save = true; } if (!props.containsKey("inbound.lengthVariance")) { props.setProperty("inbound.lengthVariance", "0"); + save = true; } if (!props.containsKey("outbound.lengthVariance")) { props.setProperty("outbound.lengthVariance", "0"); + save = true; } if (!props.containsKey(PROP_BOB_HOST)) { props.setProperty(PROP_BOB_HOST, "localhost"); + save = true; + } + // PROP_RELIABILITY_NONE, PROP_RELIABILITY_BEST_EFFORT, PROP_RELIABILITY_GUARANTEED + if (!props.containsKey(PROP_CFG_VER)) { + props.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_NONE); + props.setProperty(PROP_CFG_VER,"1"); + save = true; } if (save) { File cfg = new File(configLocation); diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java index 39633881e..99990e0b5 100644 --- a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java +++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java @@ -197,6 +197,9 @@ public class I2CPMessageReader { } } _stream = null; + _listener = null; + _reader = null; + _readerThread = null; } } } diff --git a/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java b/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java index d713b678d..55b29b310 100644 --- a/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java +++ b/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java @@ -11,11 +11,13 @@ import net.i2p.util.I2PThread; * @since 0.8.3 */ public class QueuedI2CPMessageReader extends I2CPMessageReader { - private final I2CPMessageQueue in; + private /* final */ I2CPMessageQueue in; public QueuedI2CPMessageReader(I2CPMessageQueue in, I2CPMessageEventListener lsnr) { super(lsnr); this.in = in; + _reader = null; + _readerThread = null; _reader = new QueuedI2CPMessageReaderRunner(); _readerThread = new I2PThread(_reader, "I2CP Internal Reader " + (++__readerId), true); } @@ -57,6 +59,10 @@ public class QueuedI2CPMessageReader extends I2CPMessageReader { } } } + super.run(); // Since we are dead, this will do some clean up, nothing else :-) + in = null; + _readerThread = null; + _reader = null; } } } diff --git a/history.txt b/history.txt index 19395eac1..ce975c687 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,10 @@ +2011-02-09 sponge + * BOB: fixup delivery in config, adds config file versioning. + * I2CP: Fix most of the I2CP leaks. Two leaks remain, but they are small. + net.i2p.internal.QueuedI2CPMessageReader and + net.i2p.router.client.I2CPMessageQueueImpl + are the two remaining leaks. + 2011-02-07 zzz * i2psnark: - Check for dup magnet torrent when adding torrent file diff --git a/router/java/src/net/i2p/router/client/QueuedClientConnectionRunner.java b/router/java/src/net/i2p/router/client/QueuedClientConnectionRunner.java index 758e8221e..61c37c1f5 100644 --- a/router/java/src/net/i2p/router/client/QueuedClientConnectionRunner.java +++ b/router/java/src/net/i2p/router/client/QueuedClientConnectionRunner.java @@ -17,7 +17,7 @@ import net.i2p.util.Log; * @since 0.8.3 */ class QueuedClientConnectionRunner extends ClientConnectionRunner { - private final I2CPMessageQueue queue; + private /* final */ I2CPMessageQueue queue; /** * Create a new runner with the given queues @@ -46,6 +46,7 @@ class QueuedClientConnectionRunner extends ClientConnectionRunner { void stopRunning() { super.stopRunning(); queue.close(); + queue = null; } /**