fixes for metadata-less torrents, and fixes for peer requests
This commit is contained in:
parent
14cb23cec2
commit
889ad70cee
|
@ -943,6 +943,10 @@ namespace libtorrent
|
||||||
, m_download_queue.end()
|
, m_download_queue.end()
|
||||||
, block_finished);
|
, block_finished);
|
||||||
|
|
||||||
|
// if there's another peer that needs to do another
|
||||||
|
// piece request, this will point to it
|
||||||
|
peer_connection* request_peer = 0;
|
||||||
|
|
||||||
if (b != m_download_queue.end())
|
if (b != m_download_queue.end())
|
||||||
{
|
{
|
||||||
if (m_assume_fifo)
|
if (m_assume_fifo)
|
||||||
|
@ -985,11 +989,7 @@ namespace libtorrent
|
||||||
if (pc && pc != this)
|
if (pc && pc != this)
|
||||||
{
|
{
|
||||||
pc->cancel_request(block_finished);
|
pc->cancel_request(block_finished);
|
||||||
if (!pc->has_peer_choked() && !t->is_seed())
|
request_peer = pc;
|
||||||
{
|
|
||||||
request_a_block(*t, *pc);
|
|
||||||
pc->send_block_requests();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1015,6 +1015,12 @@ namespace libtorrent
|
||||||
t->received_redundant_data(t->block_size());
|
t->received_redundant_data(t->block_size());
|
||||||
pol.block_finished(*this, block_finished);
|
pol.block_finished(*this, block_finished);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
|
|
||||||
|
if (request_peer && !request_peer->has_peer_choked() && !t->is_seed())
|
||||||
|
{
|
||||||
|
request_a_block(*t, *request_peer);
|
||||||
|
request_peer->send_block_requests();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,6 +1035,12 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
catch (std::exception const&) {}
|
catch (std::exception const&) {}
|
||||||
|
|
||||||
|
if (request_peer && !request_peer->has_peer_choked() && !t->is_seed())
|
||||||
|
{
|
||||||
|
request_a_block(*t, *request_peer);
|
||||||
|
request_peer->send_block_requests();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1765,7 +1777,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// the upload queue should not have non-prioritized peers
|
// the upload queue should not have non-prioritized peers
|
||||||
t->request_bandwidth(upload_channel, self(), /*m_non_prioritized*/ false);
|
t->request_bandwidth(upload_channel, self(), false);
|
||||||
m_writing = true;
|
m_writing = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2199,10 +2199,17 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type total_done = quantized_bytes_done();
|
size_type total_done = quantized_bytes_done();
|
||||||
if (is_seed())
|
if (m_torrent_file.is_valid())
|
||||||
assert(total_done == m_torrent_file.total_size());
|
{
|
||||||
|
if (is_seed())
|
||||||
|
assert(total_done == m_torrent_file.total_size());
|
||||||
|
else
|
||||||
|
assert(total_done != m_torrent_file.total_size());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
assert(total_done != m_torrent_file.total_size());
|
{
|
||||||
|
assert(total_done == 0);
|
||||||
|
}
|
||||||
|
|
||||||
// This check is very expensive.
|
// This check is very expensive.
|
||||||
assert(m_num_pieces
|
assert(m_num_pieces
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace libtorrent
|
||||||
// just the necessary to use it with piece manager
|
// just the necessary to use it with piece manager
|
||||||
// used for torrents with no metadata
|
// used for torrents with no metadata
|
||||||
torrent_info::torrent_info(sha1_hash const& info_hash)
|
torrent_info::torrent_info(sha1_hash const& info_hash)
|
||||||
: m_piece_length(256 * 1024)
|
: m_piece_length(0)
|
||||||
, m_total_size(0)
|
, m_total_size(0)
|
||||||
, m_info_hash(info_hash)
|
, m_info_hash(info_hash)
|
||||||
, m_name()
|
, m_name()
|
||||||
|
@ -250,7 +250,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_info::torrent_info()
|
torrent_info::torrent_info()
|
||||||
: m_piece_length(256 * 1024)
|
: m_piece_length(0)
|
||||||
, m_total_size(0)
|
, m_total_size(0)
|
||||||
, m_info_hash(0)
|
, m_info_hash(0)
|
||||||
, m_name()
|
, m_name()
|
||||||
|
@ -543,18 +543,18 @@ namespace libtorrent
|
||||||
m_files.push_back(e);
|
m_files.push_back(e);
|
||||||
|
|
||||||
m_total_size += size;
|
m_total_size += size;
|
||||||
|
|
||||||
|
if (m_piece_length == 0)
|
||||||
|
m_piece_length = 256 * 1024;
|
||||||
|
|
||||||
int num_pieces = static_cast<int>(
|
int num_pieces = static_cast<int>(
|
||||||
(m_total_size + m_piece_length - 1) / m_piece_length);
|
(m_total_size + m_piece_length - 1) / m_piece_length);
|
||||||
int old_num_pieces = static_cast<int>(m_piece_hash.size());
|
int old_num_pieces = static_cast<int>(m_piece_hash.size());
|
||||||
|
|
||||||
m_piece_hash.resize(num_pieces);
|
m_piece_hash.resize(num_pieces);
|
||||||
for (std::vector<sha1_hash>::iterator i = m_piece_hash.begin() + old_num_pieces;
|
if (num_pieces > old_num_pieces)
|
||||||
i != m_piece_hash.end(); ++i)
|
std::for_each(m_piece_hash.begin() + old_num_pieces
|
||||||
{
|
, m_piece_hash.end(), boost::bind(&sha1_hash::clear, _1));
|
||||||
i->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent_info::add_url_seed(std::string const& url)
|
void torrent_info::add_url_seed(std::string const& url)
|
||||||
|
|
Loading…
Reference in New Issue