From 1091a289d277707f0797d20f0426db0a9ab404f7 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sat, 6 Sep 2008 13:49:31 +0000
Subject: [PATCH]     * NTCP: Mark unreachable on outbound connection timeout

---
 .../net/i2p/router/transport/ntcp/EventPumper.java   | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java b/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java
index b5100bb8fd..98dcba0d9d 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java
@@ -422,15 +422,19 @@ public class EventPumper implements Runnable {
                 _context.statManager().addRateData("ntcp.connectSuccessful", 1, 0);
             } else {
                 con.close();
+                _transport.markUnreachable(con.getRemotePeer().calculateHash());
                 _context.statManager().addRateData("ntcp.connectFailedTimeout", 1, 0);
             }
-        } catch (IOException ioe) {
-            if (_log.shouldLog(Log.DEBUG)) _log.debug("Error processing connection", ioe);
+        } catch (IOException ioe) {   // this is the usual failure path for a timeout or connect refused
+            if (_log.shouldLog(Log.WARN))
+                _log.warn("Failed outbound connection to " + con.getRemotePeer().calculateHash(), ioe);
             con.close();
+            //_context.shitlist().shitlistRouter(con.getRemotePeer().calculateHash(), "Error connecting", NTCPTransport.STYLE);
+            _transport.markUnreachable(con.getRemotePeer().calculateHash());
             _context.statManager().addRateData("ntcp.connectFailedTimeoutIOE", 1, 0);
         } catch (NoConnectionPendingException ncpe) {
-	    // ignore
-	}
+            // ignore
+        }
     }
     
     private void processRead(SelectionKey key) {
-- 
GitLab