fixed bugs introduced in the http tracker refactoring and the fastresume data writer when the piece picker was deallocated, reported by Massaroddel

This commit is contained in:
Arvid Norberg 2006-12-12 12:56:18 +00:00
parent fcf211378a
commit ef9c2aba66
3 changed files with 10 additions and 26 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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<int>(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<piece_picker::downloading_piece>& q
= p.get_download_queue();
// blocks per piece
int num_blocks_per_piece =
static_cast<int>(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();