forked from premiere/premiere-libtorrent
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:
parent
108dfacd4d
commit
8f14c74be8
|
@ -937,6 +937,10 @@ namespace libtorrent
|
||||||
time_point m_last_receive;
|
time_point m_last_receive;
|
||||||
time_point m_last_sent;
|
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
|
// 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
|
// for request timeout. it doesn't necessarily represent the time when a
|
||||||
// specific request was made. Since requests can be handled out-of-order,
|
// specific request was made. Since requests can be handled out-of-order,
|
||||||
|
|
|
@ -137,6 +137,7 @@ namespace libtorrent
|
||||||
, m_last_choke(min_time())
|
, m_last_choke(min_time())
|
||||||
, m_last_receive(aux::time_now())
|
, m_last_receive(aux::time_now())
|
||||||
, m_last_sent(aux::time_now())
|
, m_last_sent(aux::time_now())
|
||||||
|
, m_last_sent_payload(aux::time_now())
|
||||||
, m_requested(min_time())
|
, m_requested(min_time())
|
||||||
, m_remote_dl_update(aux::time_now())
|
, m_remote_dl_update(aux::time_now())
|
||||||
, m_connect(aux::time_now())
|
, m_connect(aux::time_now())
|
||||||
|
@ -4824,10 +4825,13 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect peers that we unchoked, but
|
// disconnect peers that we unchoked, but they didn't send a request in
|
||||||
// they didn't send a request within 60 seconds.
|
// 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
|
// 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
|
if (may_timeout
|
||||||
&& !m_connecting
|
&& !m_connecting
|
||||||
&& m_requests.empty()
|
&& m_requests.empty()
|
||||||
|
@ -5220,6 +5224,7 @@ namespace libtorrent
|
||||||
, boost::bind(&peer_connection::on_disk_read_complete
|
, boost::bind(&peer_connection::on_disk_read_complete
|
||||||
, self(), _1, r, clock_type::now()), this);
|
, self(), _1, r, clock_type::now()), this);
|
||||||
}
|
}
|
||||||
|
m_last_sent_payload = clock_type::now();
|
||||||
m_requests.erase(m_requests.begin() + i);
|
m_requests.erase(m_requests.begin() + i);
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
|
|
Loading…
Reference in New Issue