From 4e0d67ef237df7e3f49a674e2dbdc76c573c5b59 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 1 Jul 2025 08:12:41 -0400 Subject: [PATCH] Streaming: Allow configured max window size higher than default to allow testing of larger sizes --- .../net/i2p/client/streaming/impl/Connection.java | 4 ++++ .../i2p/client/streaming/impl/ConnectionOptions.java | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/Connection.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/Connection.java index 74deb2af9..e0b46214b 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/impl/Connection.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/Connection.java @@ -110,6 +110,10 @@ class Connection { public static final int DEFAULT_CONNECT_TIMEOUT = 60*1000; private static final long MAX_CONNECT_TIMEOUT = 2*60*1000; + /** + * This is the default maximum. See ConnectionOptions.setMaxWindowSize() + * where the configured maximum is enforced. + */ public static final int MAX_WINDOW_SIZE = 128; private static final int UNCHOKES_TO_SEND = 8; diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionOptions.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionOptions.java index d906e61b6..9b81a286e 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionOptions.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionOptions.java @@ -425,7 +425,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl { //setWriteTimeout(getInt(opts, PROP_WRITE_TIMEOUT, -1)); setInactivityTimeout(getInt(opts, PROP_INACTIVITY_TIMEOUT, DEFAULT_INACTIVITY_TIMEOUT)); setInactivityAction(getInt(opts, PROP_INACTIVITY_ACTION, DEFAULT_INACTIVITY_ACTION)); - setInboundBufferSize(getMaxMessageSize() * (Connection.MAX_WINDOW_SIZE + 2)); + setInboundBufferSize(getMaxMessageSize() * (getMaxWindowSize() + 2)); setCongestionAvoidanceGrowthRateFactor(getInt(opts, PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR, DEFAULT_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR)); setSlowStartGrowthRateFactor(getInt(opts, PROP_SLOW_START_GROWTH_RATE_FACTOR, @@ -487,7 +487,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl { setInactivityTimeout(getInt(opts, PROP_INACTIVITY_TIMEOUT, DEFAULT_INACTIVITY_TIMEOUT)); if (opts.getProperty(PROP_INACTIVITY_ACTION) != null) setInactivityAction(getInt(opts, PROP_INACTIVITY_ACTION, DEFAULT_INACTIVITY_ACTION)); - setInboundBufferSize(getMaxMessageSize() * (Connection.MAX_WINDOW_SIZE + 2)); + setInboundBufferSize(getMaxMessageSize() * (getMaxWindowSize() + 2)); if (opts.getProperty(PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR) != null) setCongestionAvoidanceGrowthRateFactor(getInt(opts, PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR, DEFAULT_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR)); @@ -843,10 +843,10 @@ class ConnectionOptions extends I2PSocketOptionsImpl { public int getMaxWindowSize() { return _maxWindowSize; } public void setMaxWindowSize(int msgs) { - if (msgs > Connection.MAX_WINDOW_SIZE) - _maxWindowSize = Connection.MAX_WINDOW_SIZE; - else if (msgs < 1) - _maxWindowSize = 1; + if (msgs > 2 * Connection.MAX_WINDOW_SIZE) + _maxWindowSize = 2 * Connection.MAX_WINDOW_SIZE; + else if (msgs < 2) + _maxWindowSize = 2; else _maxWindowSize = msgs; }