forked from premiere/premiere-libtorrent
parole mode improvement. Doesn't clear out the request queue when choked by a peer on parole anymore
This commit is contained in:
parent
995485daeb
commit
28113c9c42
|
@ -802,9 +802,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
while (!request_queue().empty())
|
while (!download_queue().empty())
|
||||||
{
|
{
|
||||||
piece_block const& b = request_queue().front();
|
piece_block const& b = download_queue().front();
|
||||||
peer_request r;
|
peer_request r;
|
||||||
r.piece = b.piece_index;
|
r.piece = b.piece_index;
|
||||||
r.start = b.block_index * t->block_size();
|
r.start = b.block_index * t->block_size();
|
||||||
|
|
|
@ -643,16 +643,13 @@ namespace libtorrent
|
||||||
m_peer_choked = true;
|
m_peer_choked = true;
|
||||||
t->get_policy().choked(*this);
|
t->get_policy().choked(*this);
|
||||||
|
|
||||||
|
if (peer_info_struct() == 0 || !peer_info_struct()->on_parole)
|
||||||
|
{
|
||||||
|
// if the peer is not in parole mode, clear the queued
|
||||||
|
// up block requests
|
||||||
if (!t->is_seed())
|
if (!t->is_seed())
|
||||||
{
|
{
|
||||||
piece_picker& p = t->picker();
|
piece_picker& p = t->picker();
|
||||||
// remove all pieces from this peers download queue and
|
|
||||||
// remove the 'downloading' flag from piece_picker.
|
|
||||||
for (std::deque<piece_block>::iterator i = m_download_queue.begin();
|
|
||||||
i != m_download_queue.end(); ++i)
|
|
||||||
{
|
|
||||||
p.abort_download(*i);
|
|
||||||
}
|
|
||||||
for (std::deque<piece_block>::const_iterator i = m_request_queue.begin()
|
for (std::deque<piece_block>::const_iterator i = m_request_queue.begin()
|
||||||
, end(m_request_queue.end()); i != end; ++i)
|
, end(m_request_queue.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
|
@ -661,10 +658,9 @@ namespace libtorrent
|
||||||
p.abort_download(*i);
|
p.abort_download(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_download_queue.clear();
|
|
||||||
m_request_queue.clear();
|
m_request_queue.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool match_request(peer_request const& r, piece_block const& b, int block_size)
|
bool match_request(peer_request const& r, piece_block const& b, int block_size)
|
||||||
{
|
{
|
||||||
|
@ -707,24 +703,18 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
b = *i;
|
b = *i;
|
||||||
m_download_queue.erase(i);
|
m_download_queue.erase(i);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i = std::find_if(m_request_queue.begin(), m_request_queue.end()
|
|
||||||
, bind(match_request, boost::cref(r), _1, t->block_size()));
|
|
||||||
|
|
||||||
if (i != m_request_queue.end())
|
// if the peer is in parole mode, keep the request
|
||||||
|
if (peer_info_struct() && peer_info_struct()->on_parole)
|
||||||
{
|
{
|
||||||
b = *i;
|
m_request_queue.push_front(b);
|
||||||
m_request_queue.erase(i);
|
|
||||||
}
|
}
|
||||||
}
|
else if (!t->is_seed())
|
||||||
|
|
||||||
if (b.piece_index != -1 && !t->is_seed())
|
|
||||||
{
|
{
|
||||||
piece_picker& p = t->picker();
|
piece_picker& p = t->picker();
|
||||||
p.abort_download(b);
|
p.abort_download(b);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue