From dcb8009c639006979a99d62a87c36ebf15152d6c Mon Sep 17 00:00:00 2001 From: zzz <zzz@i2pmail.org> Date: Thu, 29 Dec 2022 12:07:48 -0500 Subject: [PATCH] Tunnels: Limit requested client tunnels during congestion This will probably also reduce builds at startup. Limits may require tweaks after further testing. --- history.txt | 3 +++ .../java/src/net/i2p/router/RouterVersion.java | 4 ++-- .../net/i2p/router/tunnel/pool/TunnelPool.java | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/history.txt b/history.txt index 1047c9dfec..cbab534126 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2022-12-29 zzz + * Tunnels: Limit requested client tunnels during congestion + 2022-12-26 zzz * Console: Sort tunnels by name on /tunnels, /configtunnels, /i2ptunnel * Router: Don't blocklist our own IP diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 470d52b4be..32c3be4234 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,10 +18,10 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Git"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 12; + public final static long BUILD = 13; /** for example "-test" */ - public final static String EXTRA = ""; + public final static String EXTRA = "-rc"; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public static void main(String args[]) { System.out.println("I2P Router version: " + FULL_VERSION); diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java index 3b556ce062..d98b87f3c9 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java @@ -332,8 +332,24 @@ public class TunnelPool { if (_settings.getLength() == 0 && _settings.getLengthVariance() == 0) return 1; int rv = _settings.getTotalQuantity(); - if (!_settings.isExploratory()) + if (!_settings.isExploratory()) { + if (rv <= 1) + return rv; + // throttle client tunnel builds in times of congestion + int fails = _consecutiveBuildTimeouts.get(); + if (fails > 4) { + if (fails > 8) { + rv = 1; + if (_log.shouldWarn()) + _log.warn("Limit to 1 tunnel after " + fails + " consec. build timeouts on " + this); + } else if (rv > 2) { + rv--; + if (_log.shouldWarn()) + _log.warn("Limit to " + rv + " tunnels after " + fails + " consec. build timeouts on " + this); + } + } return rv; + } // TODO high-bw non-ff also if (_context.netDb().floodfillEnabled() && _context.router().getUptime() > 5*60*1000) { -- GitLab