lt sync 1694

This commit is contained in:
Marcos Pinto 2007-10-25 22:20:56 +00:00
parent cbeb2c6e6c
commit 4bb1f06fd3
6 changed files with 18 additions and 8 deletions

View File

@ -357,6 +357,7 @@ namespace libtorrent
// the different priority levels // the different priority levels
switch (piece_priority) switch (piece_priority)
{ {
case 1: return prio;
case 2: return prio - 1; case 2: return prio - 1;
case 3: return (std::max)(prio / 2, 1); case 3: return (std::max)(prio / 2, 1);
case 4: return (std::max)(prio / 2 - 1, 1); case 4: return (std::max)(prio / 2 - 1, 1);

View File

@ -111,6 +111,7 @@ namespace libtorrent
, initial_picker_threshold(4) , initial_picker_threshold(4)
, allowed_fast_set_size(10) , allowed_fast_set_size(10)
, max_outstanding_disk_bytes_per_connection(64 * 1024) , max_outstanding_disk_bytes_per_connection(64 * 1024)
, handshake_timeout(10)
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
, use_dht_as_fallback(true) , use_dht_as_fallback(true)
#endif #endif
@ -270,6 +271,11 @@ namespace libtorrent
// to not completely disrupt normal downloads. // to not completely disrupt normal downloads.
int max_outstanding_disk_bytes_per_connection; 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 #ifndef TORRENT_DISABLE_DHT
// while this is true, the dht will note be used unless the // while this is true, the dht will note be used unless the
// tracker is online // tracker is online

View File

@ -240,8 +240,8 @@ namespace libtorrent
void parse_info_section(entry const& e); void parse_info_section(entry const& e);
entry extra(char const* key) const entry const* extra(char const* key) const
{ return m_extra_info[key]; } { return m_extra_info.find_key(key); }
// frees parts of the metadata that isn't // frees parts of the metadata that isn't
// used by seeds // used by seeds

View File

@ -342,6 +342,10 @@ namespace libtorrent
try { if (handler) handler(ret, j); } try { if (handler) handler(ret, j); }
catch (std::exception&) {} catch (std::exception&) {}
#ifndef NDEBUG
m_current.storage = 0;
#endif
if (j.buffer && free_buffer) if (j.buffer && free_buffer)
{ {
l.lock(); l.lock();

View File

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

View File

@ -1526,7 +1526,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_ses.m_logger) << time_now_string() << " resolving: " << url << "\n"; (*m_ses.m_logger) << time_now_string() << " resolving web seed: " << url << "\n";
#endif #endif
m_resolving_web_seeds.insert(url); m_resolving_web_seeds.insert(url);