From 4bb1f06fd346f5dcf00756de09501e8435329282 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 25 Oct 2007 22:20:56 +0000 Subject: [PATCH] lt sync 1694 --- libtorrent/include/libtorrent/piece_picker.hpp | 1 + libtorrent/include/libtorrent/session_settings.hpp | 6 ++++++ libtorrent/include/libtorrent/torrent_info.hpp | 4 ++-- libtorrent/src/disk_io_thread.cpp | 4 ++++ libtorrent/src/peer_connection.cpp | 9 ++++----- libtorrent/src/torrent.cpp | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libtorrent/include/libtorrent/piece_picker.hpp b/libtorrent/include/libtorrent/piece_picker.hpp index 2c62e5d8b..ef69c3334 100755 --- a/libtorrent/include/libtorrent/piece_picker.hpp +++ b/libtorrent/include/libtorrent/piece_picker.hpp @@ -357,6 +357,7 @@ namespace libtorrent // the different priority levels switch (piece_priority) { + case 1: return prio; case 2: return prio - 1; case 3: return (std::max)(prio / 2, 1); case 4: return (std::max)(prio / 2 - 1, 1); diff --git a/libtorrent/include/libtorrent/session_settings.hpp b/libtorrent/include/libtorrent/session_settings.hpp index 8d57b27ec..7b08ec11e 100644 --- a/libtorrent/include/libtorrent/session_settings.hpp +++ b/libtorrent/include/libtorrent/session_settings.hpp @@ -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 diff --git a/libtorrent/include/libtorrent/torrent_info.hpp b/libtorrent/include/libtorrent/torrent_info.hpp index 89744d0af..16eebf234 100755 --- a/libtorrent/include/libtorrent/torrent_info.hpp +++ b/libtorrent/include/libtorrent/torrent_info.hpp @@ -240,8 +240,8 @@ namespace libtorrent void parse_info_section(entry const& e); - entry extra(char const* key) const - { return m_extra_info[key]; } + entry const* extra(char const* key) const + { return m_extra_info.find_key(key); } // frees parts of the metadata that isn't // used by seeds diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index 1bec3b76b..ec5b8d8da 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/src/disk_io_thread.cpp @@ -341,6 +341,10 @@ namespace libtorrent // else std::cerr << "DISK THREAD: invoking callback" << std::endl; try { if (handler) handler(ret, j); } catch (std::exception&) {} + +#ifndef NDEBUG + m_current.storage = 0; +#endif if (j.buffer && free_buffer) { diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index 2032b54c5..5def3438d 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -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; } diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index d14b3075d..719f56853 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -1526,7 +1526,7 @@ namespace libtorrent INVARIANT_CHECK; #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 m_resolving_web_seeds.insert(url);