From 33add5bb91b57d8ce399a49de77644f7e87c98a4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 17 Sep 2007 02:29:33 +0000 Subject: [PATCH] added a shorter timeout while waiting for a hanshake response from peers --- src/peer_connection.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 7832b4444..59031cc18 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2915,11 +2915,6 @@ namespace libtorrent // TODO: the timeout should be called by an event INVARIANT_CHECK; -#ifndef NDEBUG - // allow step debugging without timing out - return false; -#endif - ptime now(time_now()); // if the socket is still connecting, don't @@ -2933,6 +2928,10 @@ namespace libtorrent d = now - m_last_receive; if (d > seconds(m_timeout)) return true; + // if it takes more than 5 seconds to receive + // handshake, disconnect + if (in_handshake() && d > seconds(5)) return true; + // disconnect peers that we unchoked, but // they didn't send a request within 20 seconds. // but only if we're a seed