diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index dab5522145c08ac41e6136ad80db363aa4a8cce2..32c58381f87d5420644bd3a2484fb026b09cecc9 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -810,6 +810,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna // connecting to the router in a delay-open or // close-on-idle tunnel (in connectManager() above) _log.error("Uncaught error in i2ptunnel client", t); + try { _s.close(); } catch (IOException ioe) {} } } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index da023eb8b8e73b5210291e3e183d906f9276c1e9..b94d2d3e4fb16a4715cc7bd1cae89f2228cbd7e7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -547,12 +547,14 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { // Never shut down. _clientExecutor = new TunnelControllerGroup.CustomThreadPoolExecutor(); } + I2PSocket i2ps = null; while (open) { try { + i2ps = null; I2PServerSocket ci2pss = i2pss; if (ci2pss == null) throw new I2PException("I2PServerSocket closed"); - final I2PSocket i2ps = ci2pss.accept(); + i2ps = ci2pss.accept(); if (i2ps == null) throw new I2PException("I2PServerSocket closed"); if (_usePool) { try { @@ -576,18 +578,22 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { _log.error("Error accepting - KILLING THE TUNNEL SERVER", ipe); // TODO delay and loop if internal router is soft restarting? open = false; + if (i2ps != null) try { i2ps.close(); } catch (IOException ioe) {} break; } catch (ConnectException ce) { if (_log.shouldLog(Log.ERROR)) _log.error("Error accepting", ce); open = false; + if (i2ps != null) try { i2ps.close(); } catch (IOException ioe) {} break; } catch(SocketTimeoutException ste) { // ignored, we never set the timeout + if (i2ps != null) try { i2ps.close(); } catch (IOException ioe) {} } catch (RuntimeException e) { // streaming borkage if (_log.shouldLog(Log.ERROR)) _log.error("Uncaught exception accepting", e); + if (i2ps != null) try { i2ps.close(); } catch (IOException ioe) {} // not killing the server.. try { Thread.sleep(500);