make 'snubbed' more sticky by only giving one request_timeout back when a new block is being received
This commit is contained in:
parent
1bdb6afebd
commit
680dab5a67
|
@ -124,6 +124,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
ptime() {}
|
ptime() {}
|
||||||
explicit ptime(boost::int64_t t): time(t) {}
|
explicit ptime(boost::int64_t t): time(t) {}
|
||||||
|
ptime& operator+=(time_duration rhs) { time += rhs.diff; return *this; }
|
||||||
|
ptime& operator-=(time_duration rhs) { time -= rhs.diff; return *this; }
|
||||||
boost::int64_t time;
|
boost::int64_t time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1513,6 +1513,8 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptime now = time_now();
|
||||||
|
|
||||||
piece_picker& picker = t->picker();
|
piece_picker& picker = t->picker();
|
||||||
piece_manager& fs = t->filesystem();
|
piece_manager& fs = t->filesystem();
|
||||||
|
|
||||||
|
@ -1582,14 +1584,14 @@ namespace libtorrent
|
||||||
m_timeout_extend = 0;
|
m_timeout_extend = 0;
|
||||||
|
|
||||||
if (!m_download_queue.empty())
|
if (!m_download_queue.empty())
|
||||||
m_requested = time_now();
|
m_requested = now;
|
||||||
|
|
||||||
request_a_block(*t, *this);
|
request_a_block(*t, *this);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_seconds(time_now() - m_requested)
|
if (total_seconds(now - m_requested)
|
||||||
< m_ses.settings().request_timeout
|
< m_ses.settings().request_timeout
|
||||||
&& m_snubbed)
|
&& m_snubbed)
|
||||||
{
|
{
|
||||||
|
@ -1607,9 +1609,17 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(m_channel_state[download_channel] == peer_info::bw_idle);
|
TORRENT_ASSERT(m_channel_state[download_channel] == peer_info::bw_idle);
|
||||||
m_download_queue.erase(b);
|
m_download_queue.erase(b);
|
||||||
|
|
||||||
m_timeout_extend = 0;
|
|
||||||
if (!m_download_queue.empty())
|
if (!m_download_queue.empty())
|
||||||
m_requested = time_now();
|
{
|
||||||
|
m_timeout_extend = (std::max)(m_timeout_extend
|
||||||
|
- m_ses.settings().request_timeout, 0);
|
||||||
|
m_requested += seconds(m_ses.settings().request_timeout);
|
||||||
|
if (m_requested > now) m_requested = now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_timeout_extend = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// did we request this block from any other peers?
|
// did we request this block from any other peers?
|
||||||
bool multi = picker.num_peers(block_finished) > 1;
|
bool multi = picker.num_peers(block_finished) > 1;
|
||||||
|
|
Loading…
Reference in New Issue