fix issue where a seed could time-out an unchoked peer for not sending any requests, despite being busy servicing requests from the peer (and time out immediately when m_requests is drained)

This commit is contained in:
arvidn 2016-03-13 16:41:31 -04:00
parent 108dfacd4d
commit 8f14c74be8
2 changed files with 12 additions and 3 deletions

View File

@ -937,6 +937,10 @@ namespace libtorrent
time_point m_last_receive;
time_point m_last_sent;
// the last time we filled our send buffer with payload
// this is used for timeouts
time_point m_last_sent_payload;
// the time when the first entry in the request queue was requested. Used
// for request timeout. it doesn't necessarily represent the time when a
// specific request was made. Since requests can be handled out-of-order,

View File

@ -137,6 +137,7 @@ namespace libtorrent
, m_last_choke(min_time())
, m_last_receive(aux::time_now())
, m_last_sent(aux::time_now())
, m_last_sent_payload(aux::time_now())
, m_requested(min_time())
, m_remote_dl_update(aux::time_now())
, m_connect(aux::time_now())
@ -4824,10 +4825,13 @@ namespace libtorrent
return;
}
// disconnect peers that we unchoked, but
// they didn't send a request within 60 seconds.
// disconnect peers that we unchoked, but they didn't send a request in
// the last 60 seconds, and we haven't been working on servicing a request
// for more than 60 seconds.
// but only if we're a seed
d = now - (std::max)(m_last_unchoke, m_last_incoming_request);
d = now - (std::min)((std::max)(m_last_unchoke, m_last_incoming_request)
, m_last_sent_payload);
if (may_timeout
&& !m_connecting
&& m_requests.empty()
@ -5220,6 +5224,7 @@ namespace libtorrent
, boost::bind(&peer_connection::on_disk_read_complete
, self(), _1, r, clock_type::now()), this);
}
m_last_sent_payload = clock_type::now();
m_requests.erase(m_requests.begin() + i);
if (m_requests.empty())