forked from premiere/premiere-libtorrent
fast reconnect fixes
This commit is contained in:
parent
282edb5861
commit
1699fa4652
|
@ -176,13 +176,7 @@ namespace libtorrent
|
|||
void set_non_prioritized(bool b)
|
||||
{ m_non_prioritized = b; }
|
||||
|
||||
void fast_reconnect(bool r)
|
||||
{
|
||||
if (peer_info_struct() && peer_info_struct()->fast_reconnects > 0) return;
|
||||
m_fast_reconnect = r;
|
||||
if (peer_info_struct()) ++peer_info_struct()->fast_reconnects;
|
||||
|
||||
}
|
||||
void fast_reconnect(bool r);
|
||||
bool fast_reconnect() const { return m_fast_reconnect; }
|
||||
|
||||
// this adds an announcement in the announcement queue
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace libtorrent
|
|||
, allow_multiple_connections_per_ip(false)
|
||||
, max_failcount(3)
|
||||
, min_reconnect_time(60)
|
||||
, peer_connect_timeout(10)
|
||||
, peer_connect_timeout(7)
|
||||
, ignore_limits_on_local_network(true)
|
||||
, connection_speed(20)
|
||||
, send_redundant_have(false)
|
||||
|
|
|
@ -204,7 +204,6 @@ namespace libtorrent
|
|||
|
||||
// if this fails, we need to reconnect
|
||||
// fast.
|
||||
pi->connected = time_now() - seconds(m_ses.settings().min_reconnect_time);
|
||||
fast_reconnect(true);
|
||||
|
||||
write_pe1_2_dhkey();
|
||||
|
|
|
@ -394,6 +394,16 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
void peer_connection::fast_reconnect(bool r)
|
||||
{
|
||||
if (peer_info_struct() && peer_info_struct()->fast_reconnects > 1) return;
|
||||
m_fast_reconnect = r;
|
||||
peer_info_struct()->connected = time_now()
|
||||
- seconds(m_ses.settings().min_reconnect_time
|
||||
* m_ses.settings().max_failcount);
|
||||
if (peer_info_struct()) ++peer_info_struct()->fast_reconnects;
|
||||
}
|
||||
|
||||
void peer_connection::announce_piece(int index)
|
||||
{
|
||||
// dont announce during handshake
|
||||
|
@ -1922,7 +1932,6 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::timed_out()
|
||||
{
|
||||
if (m_peer_info) ++m_peer_info->failcount;
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_ses.m_logger) << "CONNECTION TIMED OUT: " << m_remote.address().to_string()
|
||||
<< "\n";
|
||||
|
|
|
@ -986,7 +986,8 @@ namespace libtorrent
|
|||
i->second.prev_amount_upload = 0;
|
||||
i->second.connection = &c;
|
||||
TORRENT_ASSERT(i->second.connection);
|
||||
i->second.connected = time_now();
|
||||
if (!c.fast_reconnect())
|
||||
i->second.connected = time_now();
|
||||
// m_last_optimistic_disconnect = time_now();
|
||||
}
|
||||
|
||||
|
|
|
@ -1678,8 +1678,6 @@ namespace libtorrent
|
|||
|
||||
try
|
||||
{
|
||||
TORRENT_ASSERT(m_connections.find(a) == m_connections.end());
|
||||
|
||||
// add the newly connected peer to this torrent's peer list
|
||||
TORRENT_ASSERT(m_connections.find(a) == m_connections.end());
|
||||
m_connections.insert(
|
||||
|
@ -1893,10 +1891,13 @@ namespace libtorrent
|
|||
std::make_pair(a, boost::get_pointer(c)));
|
||||
m_ses.m_connections.insert(std::make_pair(s, c));
|
||||
|
||||
int timeout = settings().peer_connect_timeout;
|
||||
if (peerinfo) timeout += 3 * peerinfo->failcount;
|
||||
|
||||
m_ses.m_half_open.enqueue(
|
||||
bind(&peer_connection::connect, c, _1)
|
||||
, bind(&peer_connection::timed_out, c)
|
||||
, seconds(settings().peer_connect_timeout));
|
||||
, seconds(timeout));
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -2400,8 +2401,6 @@ namespace libtorrent
|
|||
|
||||
piece_manager& torrent::filesystem()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
TORRENT_ASSERT(m_owning_storage.get());
|
||||
return *m_owning_storage;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue