From 54fb91ba8e8c5c9fc863984c3e7a031ef601c72c Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 23 Nov 2013 17:54:01 +0000 Subject: [PATCH] I2PTunnel: Call destroySocketManager() when replacing a client socket manager configured with i2cp.newDestOnResume, or a shared client. This prevents lots of orphaned StreamingTimer threads. There are still cases where these threads may stick around, when a tunnel is stopped but not restarted. We don't know in some cases when a tunnel could be restarted and when it can't. destroySocketManager() should always be called when discarding a SocketManager but i2ptunnel doesn't do that now. More to do, but this fixes the most common case of leaked threads. Related tickets: ##642 #961 --- .../java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index 807818d44b..2ba6acc11f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -263,6 +263,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna getTunnel().removeSession(sess); if (_log.shouldLog(Log.WARN)) _log.warn(getTunnel().getClientOptions().getProperty("inbound.nickname") + ": Built a new destination on resume"); + // make sure the old one is closed + sockMgr.destroySocketManager(); newManager = true; } // else the old socket manager will reconnect the old session if necessary } @@ -320,6 +322,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna if (_log.shouldLog(Log.INFO)) _log.info(tunnel.getClientOptions().getProperty("inbound.nickname") + ": Building a new socket manager since the old one closed [s=" + s + "]"); tunnel.removeSession(s); + // make sure the old one is closed + socketManager.destroySocketManager(); // We could be here a LONG time, holding the lock socketManager = buildSocketManager(tunnel, pkf); } else { -- GitLab