From 9ec79f50fae252b57fbfd560a012f28110e5036f Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sun, 10 Jan 2010 16:38:34 +0000
Subject: [PATCH]     * I2CP: Clean up resources on 5-minute leaseset timeout
 at startup

---
 core/java/src/net/i2p/client/I2PSessionImpl.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java
index b1fc2b2266..7fdb17d004 100644
--- a/core/java/src/net/i2p/client/I2PSessionImpl.java
+++ b/core/java/src/net/i2p/client/I2PSessionImpl.java
@@ -289,8 +289,10 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
             if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After getDate / begin waiting for a response");
             int waitcount = 0;
             while (!_dateReceived) {
-                if (waitcount++ > 30)
+                if (waitcount++ > 30) {
+                    closeSocket();
                     throw new IOException("no date handshake");
+                }
                 try {
                     synchronized (_dateReceivedLock) {
                         _dateReceivedLock.wait(1000);
@@ -307,8 +309,13 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
             // wait until we have created a lease set
             waitcount = 0;
             while (_leaseSet == null) {
-                if (waitcount++ > 5*60)
+                if (waitcount++ > 5*60) {
+                    try {
+                        _producer.disconnect(this);
+                    } catch (I2PSessionException ipe) {}
+                    closeSocket();
                     throw new IOException("no leaseset");
+                }
                 synchronized (_leaseSetWait) {
                     try {
                         _leaseSetWait.wait(1000);
-- 
GitLab