Merge pull request #542 from arvidn/request-timeout-1.1

fix seed timing-out unchoked peers for not sending requests
This commit is contained in:
Arvid Norberg 2016-03-14 01:44:50 -04:00
commit 035f8e98d1
4 changed files with 20 additions and 9 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

@ -68,7 +68,7 @@ TORRENT_TEST(plain)
// terminate
, [](int ticks, lt::session& ses) -> bool
{
if (ticks > 75)
if (ticks > 80)
{
TEST_ERROR("timeout");
return true;
@ -109,7 +109,7 @@ TORRENT_TEST(session_stats)
, [](int ticks, lt::session& ses) -> bool
{
ses.post_session_stats();
if (ticks > 75)
if (ticks > 80)
{
TEST_ERROR("timeout");
return true;
@ -135,7 +135,7 @@ TORRENT_TEST(suggest)
// terminate
, [](int ticks, lt::session& ses) -> bool
{
if (ticks > 75)
if (ticks > 80)
{
TEST_ERROR("timeout");
return true;
@ -163,7 +163,7 @@ TORRENT_TEST(utp_only)
// terminate
, [](int ticks, lt::session& ses) -> bool
{
if (ticks > 75)
if (ticks > 80)
{
TEST_ERROR("timeout");
return true;
@ -322,7 +322,7 @@ TORRENT_TEST(explicit_cache)
// terminate
, [](int ticks, lt::session& ses) -> bool
{
if (ticks > 75)
if (ticks > 80)
{
TEST_ERROR("timeout");
return true;

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::max)((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())

View File

@ -65,7 +65,9 @@ static struct utp_logger
FILE* utp_log_file;
mutex utp_log_mutex;
utp_logger() : utp_log_file(NULL) {}
utp_logger() : utp_log_file(NULL) {
utp_log_file = fopen("utp.log", "w+");
}
~utp_logger()
{
if (utp_log_file) fclose(utp_log_file);