From de5dd796d03887a4a4697c8d6965dc3686474303 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 26 Aug 2008 01:03:39 +0000 Subject: [PATCH] lt sync 2637 --- libtorrent/include/libtorrent/alert_types.hpp | 8 +++----- libtorrent/include/libtorrent/piece_picker.hpp | 1 + libtorrent/src/peer_connection.cpp | 4 ++-- libtorrent/src/piece_picker.cpp | 16 +++++++++++++--- libtorrent/src/session_impl.cpp | 8 +++++++- libtorrent/src/torrent.cpp | 1 - 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/libtorrent/include/libtorrent/alert_types.hpp b/libtorrent/include/libtorrent/alert_types.hpp index e85f3ed0d..445845caa 100644 --- a/libtorrent/include/libtorrent/alert_types.hpp +++ b/libtorrent/include/libtorrent/alert_types.hpp @@ -1009,9 +1009,8 @@ namespace libtorrent virtual std::string message() const { error_code ec; - return "listening on " + endpoint.address().to_string(ec) + ":" - + boost::lexical_cast(endpoint.port()) + " failed: " - + error.message(); + return "listening on " + boost::lexical_cast(endpoint) + + " failed: " + error.message(); } }; @@ -1031,8 +1030,7 @@ namespace libtorrent virtual std::string message() const { error_code ec; - return "successfully listening on " + endpoint.address().to_string(ec) - + ":" + boost::lexical_cast(endpoint.port()); + return "successfully listening on " + boost::lexical_cast(endpoint); } }; diff --git a/libtorrent/include/libtorrent/piece_picker.hpp b/libtorrent/include/libtorrent/piece_picker.hpp index bd0f862b6..5bcae3c96 100644 --- a/libtorrent/include/libtorrent/piece_picker.hpp +++ b/libtorrent/include/libtorrent/piece_picker.hpp @@ -161,6 +161,7 @@ namespace libtorrent void we_have(int index); void we_dont_have(int index); + // sets all pieces to dont-have void init(int blocks_per_piece, int total_num_blocks); int num_pieces() const { return int(m_piece_map.size()); } diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index fa9cffe44..e72239abc 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -1588,8 +1588,8 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING (*m_logger) << time_now_string() - << " *** SKIPPED_PIECE [ piece: " << eq.block.piece_index << " | " - "b: " << eq.block.block_index << " ] ***\n"; + << " *** SKIPPED_PIECE [ piece: " << qe.block.piece_index << " | " + "b: " << qe.block.block_index << " ] ***\n"; #endif ++qe.skipped; diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index b6dbc2a82..bb0b460a3 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -82,6 +82,18 @@ namespace libtorrent m_piece_map.resize((total_num_blocks + blocks_per_piece-1) / blocks_per_piece , piece_pos(0, 0)); + m_num_filtered += m_num_have_filtered; + m_num_have_filtered = 0; + m_num_have = 0; + m_dirty = true; + for (std::vector::iterator i = m_piece_map.begin() + , end(m_piece_map.end()); i != end; ++i) + { + i->peer_count = 0; + i->downloading = 0; + i->index = 0; + } + // the piece index is stored in 20 bits, which limits the allowed // number of pieces somewhat if (m_piece_map.size() >= piece_pos::we_have_index) @@ -1074,7 +1086,7 @@ namespace libtorrent if (new_piece_priority == int(p.piece_priority)) return false; int prev_priority = p.priority(this); - TORRENT_ASSERT(prev_priority < int(m_priority_boundries.size())); + TORRENT_ASSERT(m_dirty | prev_priority < int(m_priority_boundries.size())); bool ret = false; if (new_piece_priority == piece_pos::filter_priority @@ -1101,8 +1113,6 @@ namespace libtorrent if (prev_priority == new_priority) return ret; - TORRENT_ASSERT(prev_priority < int(m_priority_boundries.size())); - if (m_dirty) return ret; if (prev_priority == -1) { diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index cca630d01..de8b73e83 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -601,7 +601,7 @@ namespace aux { return listen_socket_t(); } s.external_port = s.sock->local_endpoint(ec).port(); - s.sock->listen(0, ec); + s.sock->listen(5, ec); if (ec) { if (m_alerts.should_post()) @@ -724,6 +724,10 @@ namespace aux { } } } + +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + m_logger = create_log("main_session", listen_port(), false); +#endif } #ifndef TORRENT_DISABLE_DHT @@ -2372,6 +2376,8 @@ namespace aux { { TORRENT_ASSERT(ip != address()); + if (is_local(ip)) return; + if (is_loopback(ip)) return; if (m_external_address == ip) return; m_external_address = ip; diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 555d48561..f0a16bd4f 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -667,7 +667,6 @@ namespace libtorrent , m_save_path, m_ses.m_files, m_ses.m_disk_thread, m_storage_constructor , m_storage_mode); m_storage = m_owning_storage.get(); - m_picker.reset(new piece_picker); m_picker->init(m_torrent_file->piece_length() / m_block_size , int((m_torrent_file->total_size()+m_block_size-1)/m_block_size)); // assume that we don't have anything