made the handshake timeout configurable and defaults to 10 seconds

This commit is contained in:
Arvid Norberg 2007-10-23 00:19:28 +00:00
parent 2662c84f01
commit f054ae7c2d
2 changed files with 10 additions and 5 deletions

View File

@ -111,6 +111,7 @@ namespace libtorrent
, initial_picker_threshold(4)
, allowed_fast_set_size(10)
, max_outstanding_disk_bytes_per_connection(64 * 1024)
, handshake_timeout(10)
#ifndef TORRENT_DISABLE_DHT
, use_dht_as_fallback(true)
#endif
@ -270,6 +271,11 @@ namespace libtorrent
// to not completely disrupt normal downloads.
int max_outstanding_disk_bytes_per_connection;
// the number of seconds to wait for a handshake
// response from a peer. If no response is received
// within this time, the peer is disconnected.
int handshake_timeout;
#ifndef TORRENT_DISABLE_DHT
// while this is true, the dht will note be used unless the
// tracker is online

View File

@ -3000,13 +3000,12 @@ namespace libtorrent
return true;
}
// if it takes more than 5 seconds to receive
// handshake, disconnect
if (in_handshake() && d > seconds(5))
// do not stall waiting for a handshake
if (in_handshake() && d > seconds(m_ses.settings().handshake_timeout))
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** NO HANDSHAKE [ "
<< total_seconds(d) << " seconds ago ] ***\n";
(*m_logger) << time_now_string() << " *** NO HANDSHAKE [ waited "
<< total_seconds(d) << " seconds ] ***\n";
#endif
return true;
}