mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-16 23:28:57 +00:00
lt sync 2518 - mostly timeout fixes
This commit is contained in:
parent
c0bc622fca
commit
2b9663edce
4 changed files with 36 additions and 4 deletions
|
@ -600,6 +600,7 @@ namespace libtorrent
|
||||||
ptime m_remote_dl_update;
|
ptime m_remote_dl_update;
|
||||||
|
|
||||||
// the time when async_connect was called
|
// the time when async_connect was called
|
||||||
|
// or when the incoming connection was established
|
||||||
ptime m_connect;
|
ptime m_connect;
|
||||||
|
|
||||||
// the time when this peer sent us a not_interested message
|
// the time when this peer sent us a not_interested message
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace libtorrent
|
||||||
, m_requested(min_time())
|
, m_requested(min_time())
|
||||||
, m_timeout_extend(0)
|
, m_timeout_extend(0)
|
||||||
, m_remote_dl_update(time_now())
|
, m_remote_dl_update(time_now())
|
||||||
|
, m_connect(time_now())
|
||||||
, m_became_uninterested(time_now())
|
, m_became_uninterested(time_now())
|
||||||
, m_became_uninteresting(time_now())
|
, m_became_uninteresting(time_now())
|
||||||
, m_free_upload(0)
|
, m_free_upload(0)
|
||||||
|
@ -187,6 +188,7 @@ namespace libtorrent
|
||||||
, m_requested(min_time())
|
, m_requested(min_time())
|
||||||
, m_timeout_extend(0)
|
, m_timeout_extend(0)
|
||||||
, m_remote_dl_update(time_now())
|
, m_remote_dl_update(time_now())
|
||||||
|
, m_connect(time_now())
|
||||||
, m_became_uninterested(time_now())
|
, m_became_uninterested(time_now())
|
||||||
, m_became_uninteresting(time_now())
|
, m_became_uninteresting(time_now())
|
||||||
, m_free_upload(0)
|
, m_free_upload(0)
|
||||||
|
@ -1511,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();
|
||||||
|
|
||||||
|
@ -1580,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)
|
||||||
{
|
{
|
||||||
|
@ -1605,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;
|
||||||
|
|
|
@ -1022,6 +1022,23 @@ namespace aux {
|
||||||
<< m_disk_thread.disk_allocations() << "\t"
|
<< m_disk_thread.disk_allocations() << "\t"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// check for incoming connections that might have timed out
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
|
for (connection_map::iterator i = m_connections.begin();
|
||||||
|
i != m_connections.end();)
|
||||||
|
{
|
||||||
|
peer_connection* p = (*i).get();
|
||||||
|
++i;
|
||||||
|
// ignore connections that already have a torrent, since they
|
||||||
|
// are ticket through the torrents' second_ticket
|
||||||
|
if (!p->associated_torrent().expired()) continue;
|
||||||
|
if (m_last_tick - p->connected_time() > seconds(m_settings.peer_connect_timeout))
|
||||||
|
p->disconnect("timeout: incoming connection");
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// second_tick every torrent
|
// second_tick every torrent
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue