fast reconnect fixes

This commit is contained in:
Marcos Pinto 2007-10-15 05:34:32 +00:00
parent 7d98d49803
commit b403530fab
7 changed files with 31 additions and 18 deletions

View File

@ -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

View File

@ -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)

View File

@ -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();

View File

@ -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";

View File

@ -986,6 +986,7 @@ namespace libtorrent
i->second.prev_amount_upload = 0;
i->second.connection = &c;
TORRENT_ASSERT(i->second.connection);
if (!c.fast_reconnect())
i->second.connected = time_now();
// m_last_optimistic_disconnect = time_now();
}

View File

@ -569,8 +569,19 @@ namespace detail
, m_checker_impl(*this)
{
#ifdef WIN32
// windows XP has a limit of 10 simultaneous connections
// windows XP has a limit on the number of
// simultaneous half-open TCP connections
DWORD windows_version = ::GetVersion();
if ((windows_version & 0xff) >= 6)
{
// on vista the limit is 5 (in home edition)
m_half_open.limit(4);
}
else
{
// on XP SP2 it's 10
m_half_open.limit(8);
}
#endif
m_bandwidth_manager[peer_connection::download_channel] = &m_download_channel;

View File

@ -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;
}