piece picker fix

This commit is contained in:
Arvid Norberg 2007-03-30 03:09:28 +00:00
parent 6c8ef08e56
commit a9d18439e9
2 changed files with 14 additions and 17 deletions

View File

@ -643,28 +643,26 @@ namespace libtorrent
assert(p.downloading == 1);
assert(!p.have());
std::vector<downloading_piece>::iterator i
= std::find_if(m_downloads.begin()
, m_downloads.end()
, has_index(index));
assert(i != m_downloads.end());
m_downloads.erase(i);
p.downloading = 0;
assert(std::find_if(m_downloads.begin()
, m_downloads.end()
, has_index(index)) == m_downloads.end());
if (p.filtered())
{
--m_num_filtered;
++m_num_have_filtered;
return;
}
if (p.have()) return;
p.set_have();
if (p.downloading)
{
std::vector<downloading_piece>::iterator i
= std::find_if(m_downloads.begin(),
m_downloads.end(),
has_index(index));
assert(i != m_downloads.end());
m_downloads.erase(i);
p.downloading = 0;
assert(std::find_if(m_downloads.begin(),
m_downloads.end(),
has_index(index)) == m_downloads.end());
}
assert(p.priority(m_sequenced_download_threshold) == 0);
move(priority, info_index);
}

View File

@ -965,10 +965,9 @@ namespace libtorrent { namespace detail
{
torrent& t = *i->second;
assert(!t.is_aborted());
if (t.should_request())
if (t.should_request() && m_external_listen_port > 0)
{
tracker_request req = t.generate_tracker_request();
assert(m_external_listen_port > 0);
req.listen_port = m_external_listen_port;
req.key = m_key;
m_tracker_manager.queue_request(m_strand, req, t.tracker_login()