metadata extension fix

This commit is contained in:
Arvid Norberg 2012-08-09 22:30:45 +00:00
parent 0685fb91bd
commit 9a11c44984
2 changed files with 7 additions and 4 deletions

View File

@ -1557,6 +1557,9 @@ namespace libtorrent
m_have_piece.set_bit(index); m_have_piece.set_bit(index);
++m_num_pieces; ++m_num_pieces;
// if the peer is downloading stuff, it must have metadata
m_has_metadata = true;
// only update the piece_picker if // only update the piece_picker if
// we have the metadata and if // we have the metadata and if
// we're not a seed (in which case // we're not a seed (in which case
@ -1576,9 +1579,6 @@ namespace libtorrent
m_remote_bytes_dled += t->torrent_file().piece_size(index); m_remote_bytes_dled += t->torrent_file().piece_size(index);
} }
// if the peer is downloading stuff, it must have metadata
m_has_metadata = true;
// it's important to not disconnect before we have // it's important to not disconnect before we have
// updated the piece picker, otherwise we will incorrectly // updated the piece picker, otherwise we will incorrectly
// decrement the piece count without first incrementing it // decrement the piece count without first incrementing it
@ -2649,6 +2649,9 @@ namespace libtorrent
m_have_piece.clear_all(); m_have_piece.clear_all();
m_num_pieces = 0; m_num_pieces = 0;
// if the peer is ready to download stuff, it must have metadata
m_has_metadata = true;
// we're never interested in a peer that doesn't have anything // we're never interested in a peer that doesn't have anything
send_not_interested(); send_not_interested();

View File

@ -424,7 +424,7 @@ namespace libtorrent { namespace
bool has_metadata() const bool has_metadata() const
{ {
return time_now() > m_request_limit; return m_pc.has_metadata() || (time_now() > m_request_limit);
} }
void failed_hash_check(ptime const& now) void failed_hash_check(ptime const& now)