From 90a4b3e1ed32fe0ee6fa0605de128f908c592b69 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 19 Aug 2008 07:22:20 +0000 Subject: [PATCH] lt sync 2613 --- libtorrent/include/libtorrent/alert_types.hpp | 2 +- libtorrent/src/piece_picker.cpp | 2 +- libtorrent/src/torrent.cpp | 45 ++++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libtorrent/include/libtorrent/alert_types.hpp b/libtorrent/include/libtorrent/alert_types.hpp index 88ce8f0dd..ffa09bbf2 100644 --- a/libtorrent/include/libtorrent/alert_types.hpp +++ b/libtorrent/include/libtorrent/alert_types.hpp @@ -166,7 +166,7 @@ namespace libtorrent virtual std::string message() const { static char const* state_str[] = - {"checking (q)", "checking", "connecting", "dl metadata" + {"checking (q)", "checking", "dl metadata" , "downloading", "finished", "seeding", "allocating"}; return torrent_alert::message() + ": state changed to: " diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index 89a8d0ba4..b6dbc2a82 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -1099,7 +1099,7 @@ namespace libtorrent p.piece_priority = new_piece_priority; int new_priority = p.priority(this); - if (prev_priority == new_priority) return false; + if (prev_priority == new_priority) return ret; TORRENT_ASSERT(prev_priority < int(m_priority_boundries.size())); diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 4f7b7ee1d..a5e394c8c 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -1800,7 +1800,6 @@ namespace libtorrent INVARIANT_CHECK; if (m_torrent_file->num_pieces() == 0) return; - bool was_finished = is_finished(); size_type position = 0; int piece_length = m_torrent_file->piece_length(); @@ -1826,7 +1825,6 @@ namespace libtorrent , bind(&set_if_greater, _1, m_file_priority[i])); } prioritize_pieces(pieces); - update_peer_interest(was_finished); } // this is called when piece priorities have been updated @@ -1836,16 +1834,18 @@ namespace libtorrent for (peer_iterator i = begin(); i != end(); ++i) (*i)->update_interest(); - // if we used to be finished, but we aren't anymore - // we may need to connect to peers again - if (!is_finished() && was_finished) - m_policy.recalculate_connect_candidates(); - // the torrent just became finished if (is_finished() && !was_finished) + { finished(); + } else if (!is_finished() && was_finished) + { + // if we used to be finished, but we aren't anymore + // we may need to connect to peers again resume_download(); + m_policy.recalculate_connect_candidates(); + } } void torrent::filter_piece(int index, bool filter) @@ -3147,9 +3147,9 @@ namespace libtorrent // to make sure we're cleared the piece picker if (is_seed()) completed(); - // disconnect all seeds - // TODO: should disconnect all peers that have the pieces we have - // not just seeds + // disconnect all seeds + // TODO: should disconnect all peers that have the pieces we have + // not just seeds std::vector seeds; for (peer_iterator i = m_connections.begin(); i != m_connections.end(); ++i) @@ -3265,6 +3265,12 @@ namespace libtorrent set_state(torrent_status::downloading); + if (m_ses.m_alerts.should_post()) + { + m_ses.m_alerts.post_alert(torrent_checked_alert( + get_handle())); + } + if (!is_seed()) { if (m_sequential_download) @@ -3274,6 +3280,13 @@ namespace libtorrent // likely to be unpaused if (m_ses.m_auto_manage_time_scaler > 1) m_ses.m_auto_manage_time_scaler = 1; + + if (is_finished()) finished(); + } + else + { + m_complete_sent = true; + finished(); } #ifndef TORRENT_DISABLE_EXTENSIONS @@ -3290,12 +3303,6 @@ namespace libtorrent } #endif - if (is_seed()) - { - m_complete_sent = true; - finished(); - } - if (!m_connections_initialized) { m_connections_initialized = true; @@ -3311,12 +3318,6 @@ namespace libtorrent } } - if (m_ses.m_alerts.should_post()) - { - m_ses.m_alerts.post_alert(torrent_checked_alert( - get_handle())); - } - m_files_checked = true; start_announcing();