increase default connect speed. minor cleanup. add logging for short lived connections
This commit is contained in:
parent
6ab596be17
commit
b9ec183e24
|
@ -589,7 +589,7 @@ namespace libtorrent
|
||||||
|
|
||||||
bool can_disconnect(error_code const& ec) const;
|
bool can_disconnect(error_code const& ec) const;
|
||||||
void incoming_dht_port(int listen_port);
|
void incoming_dht_port(int listen_port);
|
||||||
|
|
||||||
void incoming_reject_request(peer_request const& r);
|
void incoming_reject_request(peer_request const& r);
|
||||||
void incoming_have_all();
|
void incoming_have_all();
|
||||||
void incoming_have_none();
|
void incoming_have_none();
|
||||||
|
|
|
@ -808,7 +808,7 @@ namespace libtorrent
|
||||||
// we support FAST extension
|
// we support FAST extension
|
||||||
*(ptr + 7) |= 0x04;
|
*(ptr + 7) |= 0x04;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
std::string bitmask;
|
std::string bitmask;
|
||||||
for (int k = 0; k < 8; ++k)
|
for (int k = 0; k < 8; ++k)
|
||||||
{
|
{
|
||||||
|
@ -3285,7 +3285,7 @@ namespace libtorrent
|
||||||
recv_buffer = m_recv_buffer.get();
|
recv_buffer = m_recv_buffer.get();
|
||||||
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
std::string extensions;
|
std::string extensions;
|
||||||
extensions.resize(8 * 8);
|
extensions.resize(8 * 8);
|
||||||
for (int i=0; i < 8; ++i)
|
for (int i=0; i < 8; ++i)
|
||||||
|
@ -3461,7 +3461,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::incoming_message, "HANDSHAKE");
|
peer_log(peer_log_alert::incoming_message, "HANDSHAKE", "connection ready");
|
||||||
#endif
|
#endif
|
||||||
// consider this a successful connection, reset the failcount
|
// consider this a successful connection, reset the failcount
|
||||||
if (peer_info_struct())
|
if (peer_info_struct())
|
||||||
|
|
|
@ -803,7 +803,7 @@ namespace libtorrent
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
if (!m_download_queue.empty())
|
if (!m_download_queue.empty())
|
||||||
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
||||||
|
|
||||||
// defensive
|
// defensive
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
// if t is NULL, we better not be connecting, since
|
// if t is NULL, we better not be connecting, since
|
||||||
|
@ -990,13 +990,13 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
return m_request_queue;
|
return m_request_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<pending_block> const& peer_connection::download_queue() const
|
std::vector<pending_block> const& peer_connection::download_queue() const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
return m_download_queue;
|
return m_download_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<peer_request> const& peer_connection::upload_queue() const
|
std::vector<peer_request> const& peer_connection::upload_queue() const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -1878,7 +1878,7 @@ namespace libtorrent
|
||||||
m_have_piece.set_bit(index);
|
m_have_piece.set_bit(index);
|
||||||
++m_num_pieces;
|
++m_num_pieces;
|
||||||
|
|
||||||
// if the peer is downloading stuff, it must have metadata
|
// if the peer is downloading stuff, it must have metadata
|
||||||
m_has_metadata = true;
|
m_has_metadata = true;
|
||||||
|
|
||||||
// only update the piece_picker if
|
// only update the piece_picker if
|
||||||
|
@ -2576,9 +2576,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
check_postcondition(boost::shared_ptr<torrent> const& t_
|
check_postcondition(boost::shared_ptr<torrent> const& t_
|
||||||
, bool init_check = true): t(t_) { if (init_check) check(); }
|
, bool init_check = true): t(t_) { if (init_check) check(); }
|
||||||
|
|
||||||
~check_postcondition() { check(); }
|
~check_postcondition() { check(); }
|
||||||
|
|
||||||
void check()
|
void check()
|
||||||
{
|
{
|
||||||
if (!t->is_seed())
|
if (!t->is_seed())
|
||||||
|
@ -2596,7 +2596,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<torrent> t;
|
shared_ptr<torrent> t;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -3229,7 +3229,7 @@ namespace libtorrent
|
||||||
|
|
||||||
disconnect_if_redundant();
|
disconnect_if_redundant();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// --------- HAVE NONE ---------
|
// --------- HAVE NONE ---------
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
@ -3495,8 +3495,8 @@ namespace libtorrent
|
||||||
|
|
||||||
if (t->alerts().should_post<block_downloading_alert>())
|
if (t->alerts().should_post<block_downloading_alert>())
|
||||||
{
|
{
|
||||||
t->alerts().emplace_alert<block_downloading_alert>(t->get_handle(),
|
t->alerts().emplace_alert<block_downloading_alert>(t->get_handle()
|
||||||
remote(), pid(), block.block_index, block.piece_index);
|
, remote(), pid(), block.block_index, block.piece_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pending_block pb(block);
|
pending_block pb(block);
|
||||||
|
@ -3643,6 +3643,8 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
TORRENT_ASSERT(!is_connecting());
|
||||||
|
|
||||||
if (m_choked)
|
if (m_choked)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_peer_info == NULL
|
TORRENT_ASSERT(m_peer_info == NULL
|
||||||
|
@ -4082,6 +4084,15 @@ namespace libtorrent
|
||||||
, op, ec.message().c_str());
|
, op, ec.message().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ec == error_code(boost::asio::error::eof
|
||||||
|
, boost::asio::error::get_misc_category())
|
||||||
|
&& !in_handshake()
|
||||||
|
&& !is_connecting()
|
||||||
|
&& clock_type::now() - connected_time() < seconds(15))
|
||||||
|
{
|
||||||
|
peer_log(peer_log_alert::info, "SHORT_LIVED_DISCONNECT", "");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((m_channel_state[upload_channel] & peer_info::bw_network) == 0)
|
if ((m_channel_state[upload_channel] & peer_info::bw_network) == 0)
|
||||||
|
@ -4955,8 +4966,8 @@ namespace libtorrent
|
||||||
boost::int64_t piece_size = t->torrent_file().piece_length();
|
boost::int64_t piece_size = t->torrent_file().piece_length();
|
||||||
|
|
||||||
if (m_remote_dl_rate > 0)
|
if (m_remote_dl_rate > 0)
|
||||||
m_remote_dl_rate = int((m_remote_dl_rate * 2 / 3) +
|
m_remote_dl_rate = int((m_remote_dl_rate * 2 / 3)
|
||||||
((boost::int64_t(m_remote_pieces_dled) * piece_size / 3) / 60));
|
+ ((boost::int64_t(m_remote_pieces_dled) * piece_size / 3) / 60));
|
||||||
else
|
else
|
||||||
m_remote_dl_rate = int(boost::int64_t(m_remote_pieces_dled)
|
m_remote_dl_rate = int(boost::int64_t(m_remote_pieces_dled)
|
||||||
* piece_size / 60);
|
* piece_size / 60);
|
||||||
|
@ -5355,7 +5366,7 @@ namespace libtorrent
|
||||||
disconnect(j->error.ec, op_file_read);
|
disconnect(j->error.ec, op_file_read);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j->ret != r.length)
|
if (j->ret != r.length)
|
||||||
{
|
{
|
||||||
// handle_disk_error may disconnect us
|
// handle_disk_error may disconnect us
|
||||||
|
@ -5715,7 +5726,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!can_read())
|
if (!can_read())
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
@ -5980,8 +5991,11 @@ namespace libtorrent
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT_VAL(error.value() != 0, error.value());
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::info, "ERROR", "in peer_connection::on_receive_data_nb error: %s"
|
peer_log(peer_log_alert::info, "ERROR"
|
||||||
|
, "in peer_connection::on_receive_data_nb error: (%s:%d) %s"
|
||||||
|
, error.category().name(), error.value()
|
||||||
, error.message().c_str());
|
, error.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
on_receive(error, bytes_transferred);
|
on_receive(error, bytes_transferred);
|
||||||
|
@ -6106,8 +6120,10 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::incoming, "ON_RECEIVE_DATA", "bytes: %d error: %s"
|
peer_log(peer_log_alert::incoming, "ON_RECEIVE_DATA"
|
||||||
, int(bytes_transferred), error.message().c_str());
|
, "bytes: %d error: (%s:%d) %s"
|
||||||
|
, int(bytes_transferred), error.category().name(), error.value()
|
||||||
|
, error.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// submit all disk jobs later
|
// submit all disk jobs later
|
||||||
|
@ -6836,7 +6852,7 @@ namespace libtorrent
|
||||||
time_duration d;
|
time_duration d;
|
||||||
d = aux::time_now() - m_last_sent;
|
d = aux::time_now() - m_last_sent;
|
||||||
if (total_seconds(d) < timeout() / 2) return;
|
if (total_seconds(d) < timeout() / 2) return;
|
||||||
|
|
||||||
if (m_connecting) return;
|
if (m_connecting) return;
|
||||||
if (in_handshake()) return;
|
if (in_handshake()) return;
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace libtorrent
|
||||||
SET(max_failcount, 3, &session_impl::update_max_failcount),
|
SET(max_failcount, 3, &session_impl::update_max_failcount),
|
||||||
SET(min_reconnect_time, 60, 0),
|
SET(min_reconnect_time, 60, 0),
|
||||||
SET(peer_connect_timeout, 15, 0),
|
SET(peer_connect_timeout, 15, 0),
|
||||||
SET(connection_speed, 6, &session_impl::update_connection_speed),
|
SET(connection_speed, 10, &session_impl::update_connection_speed),
|
||||||
SET(inactivity_timeout, 600, 0),
|
SET(inactivity_timeout, 600, 0),
|
||||||
SET(unchoke_interval, 15, 0),
|
SET(unchoke_interval, 15, 0),
|
||||||
SET(optimistic_unchoke_interval, 30, 0),
|
SET(optimistic_unchoke_interval, 30, 0),
|
||||||
|
|
Loading…
Reference in New Issue