From ef9c2aba6608b02398361f3df2fa672536fe1f87 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 12 Dec 2006 12:56:18 +0000 Subject: [PATCH] fixed bugs introduced in the http tracker refactoring and the fastresume data writer when the piece picker was deallocated, reported by Massaroddel --- ChangeLog | 2 ++ src/http_tracker_connection.cpp | 24 +++--------------------- src/torrent_handle.cpp | 10 +++++----- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82a2b8be9..d1a25b2c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * fixed bug where the http header parser was case sensitive to the header + names. * Implemented an optmization which frees the piece_picker once a torrent turns into a seed. * Added support for uT peer exchange extension, implemented by Massaroddel. diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index d4d9f3625..fca98febf 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -171,21 +171,7 @@ namespace libtorrent } catch(boost::bad_lexical_cast&) {} } -/* else if (name == "content-encoding") - { - if (value == "gzip" || value == "x-gzip") - { - m_content_encoding = gzip; - } - else - { - std::string error_str = "unknown content encoding in response: \""; - error_str += value; - error_str += "\""; - throw std::runtime_error(error_str); - } - } -*/ + // TODO: make sure we don't step outside of the buffer ++pos; ++m_recv_pos; @@ -242,16 +228,12 @@ namespace libtorrent , std::string const& auth) : tracker_connection(man, req, d, c) , m_man(man) -// , m_state(read_status) -// , m_content_encoding(plain) -// , m_content_length(0) , m_name_lookup(d) , m_port(port) , m_recv_pos(0) , m_buffer(http_buffer_size) , m_settings(stn) , m_password(auth) -// , m_code(0) , m_timed_out(false) { const std::string* connect_to_host; @@ -535,7 +517,7 @@ namespace libtorrent return; } - if (cl < minimum_tracker_response_length && m_parser.status_code() == 200) + if (cl > 0 && cl < minimum_tracker_response_length && m_parser.status_code() == 200) { fail(-1, "content-length is smaller than minimum response length"); return; @@ -561,7 +543,7 @@ namespace libtorrent void http_tracker_connection::on_response() { - if (!m_parser.finished()) + if (!m_parser.header_finished()) { fail(-1, "premature end of file"); return; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 303c5d86d..92f62e61c 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -455,6 +455,11 @@ namespace libtorrent entry::list_type& slots = ret["slots"].list(); std::copy(piece_index.begin(), piece_index.end(), std::back_inserter(slots)); + // blocks per piece + int num_blocks_per_piece = + static_cast(t->torrent_file().piece_length()) / t->block_size(); + ret["blocks per piece"] = num_blocks_per_piece; + // if this torrent is a seed, we won't have a piece picker // and there will be no half-finished pieces. if (!t->is_seed()) @@ -464,11 +469,6 @@ namespace libtorrent const std::vector& q = p.get_download_queue(); - // blocks per piece - int num_blocks_per_piece = - static_cast(t->torrent_file().piece_length()) / t->block_size(); - ret["blocks per piece"] = num_blocks_per_piece; - // unfinished pieces ret["unfinished"] = entry::list_type(); entry::list_type& up = ret["unfinished"].list();