separate stats counters from session_interface (this was the main use of m_ses in peer connections)
This commit is contained in:
parent
14f02a4475
commit
01640e1682
|
@ -1179,9 +1179,6 @@ namespace libtorrent
|
||||||
FILE* get_request_log() { return m_request_log; }
|
FILE* get_request_log() { return m_request_log; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boost::uint64_t inc_stats_counter(int c, int value = 1)
|
|
||||||
{ return m_stats_counters.inc_stats_counter(c, value); }
|
|
||||||
|
|
||||||
counters& stats_counters() { return m_stats_counters; }
|
counters& stats_counters() { return m_stats_counters; }
|
||||||
|
|
||||||
void received_buffer(int size);
|
void received_buffer(int size);
|
||||||
|
@ -1306,6 +1303,7 @@ namespace libtorrent
|
||||||
bool m_paused;
|
bool m_paused;
|
||||||
|
|
||||||
// redundant bytes per category
|
// redundant bytes per category
|
||||||
|
// TODO: 3 turn this into a stats_counter
|
||||||
size_type m_redundant_bytes[7];
|
size_type m_redundant_bytes[7];
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<feed> > m_feeds;
|
std::vector<boost::shared_ptr<feed> > m_feeds;
|
||||||
|
|
|
@ -335,7 +335,6 @@ namespace libtorrent { namespace aux
|
||||||
virtual std::ofstream& buffer_usage_logger() = 0;
|
virtual std::ofstream& buffer_usage_logger() = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual boost::uint64_t inc_stats_counter(int c, int value = 1) = 0;
|
|
||||||
virtual counters& stats_counters() = 0;
|
virtual counters& stats_counters() = 0;
|
||||||
virtual void received_buffer(int size) = 0;
|
virtual void received_buffer(int size) = 0;
|
||||||
virtual void sent_buffer(int size) = 0;
|
virtual void sent_buffer(int size) = 0;
|
||||||
|
|
|
@ -88,6 +88,7 @@ namespace libtorrent
|
||||||
bt_peer_connection(
|
bt_peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::shared_ptr<socket_type> s
|
, boost::shared_ptr<socket_type> s
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace libtorrent
|
||||||
http_seed_connection(
|
http_seed_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
|
|
|
@ -149,16 +149,16 @@ namespace libtorrent
|
||||||
|
|
||||||
struct peer_connection_hot_members
|
struct peer_connection_hot_members
|
||||||
{
|
{
|
||||||
|
// if tor is set, this is an outgoing connection
|
||||||
peer_connection_hot_members(
|
peer_connection_hot_members(
|
||||||
boost::weak_ptr<torrent> t
|
boost::weak_ptr<torrent> t
|
||||||
, aux::session_interface& ses
|
, aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett)
|
||||||
, bool outgoing)
|
|
||||||
: m_torrent(t)
|
: m_torrent(t)
|
||||||
, m_ses(ses)
|
, m_ses(ses)
|
||||||
, m_settings(sett)
|
, m_settings(sett)
|
||||||
, m_disconnecting(false)
|
, m_disconnecting(false)
|
||||||
, m_connecting(outgoing)
|
, m_connecting(!t.expired())
|
||||||
, m_endgame_mode(false)
|
, m_endgame_mode(false)
|
||||||
, m_snubbed(false)
|
, m_snubbed(false)
|
||||||
, m_interesting(false)
|
, m_interesting(false)
|
||||||
|
@ -283,14 +283,14 @@ namespace libtorrent
|
||||||
peer_connection(
|
peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, io_service& ios
|
, io_service& ios
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
, boost::shared_ptr<socket_type> s
|
, boost::shared_ptr<socket_type> s
|
||||||
, tcp::endpoint const& remote
|
, tcp::endpoint const& remote
|
||||||
, torrent_peer* peerinfo
|
, torrent_peer* peerinfo);
|
||||||
, bool outgoing = true);
|
|
||||||
|
|
||||||
// this function is called after it has been constructed and properly
|
// this function is called after it has been constructed and properly
|
||||||
// reference counted. It is safe to call self() in this function
|
// reference counted. It is safe to call self() in this function
|
||||||
|
@ -761,9 +761,7 @@ namespace libtorrent
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 2 temporary hack until the stats counters are moved out
|
counters& stats_counters() const { return m_counters; }
|
||||||
// from the session_interface. This is used by ut_pex and ut_metadata.
|
|
||||||
aux::session_interface& ses() { return m_ses; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -891,6 +889,9 @@ namespace libtorrent
|
||||||
// and hasn't been added to a torrent yet.
|
// and hasn't been added to a torrent yet.
|
||||||
torrent_peer* m_peer_info;
|
torrent_peer* m_peer_info;
|
||||||
|
|
||||||
|
// stats counters
|
||||||
|
counters& m_counters;
|
||||||
|
|
||||||
// the number of pieces this peer
|
// the number of pieces this peer
|
||||||
// has. Must be the same as
|
// has. Must be the same as
|
||||||
// std::count(m_have_piece.begin(),
|
// std::count(m_have_piece.begin(),
|
||||||
|
|
|
@ -1074,6 +1074,8 @@ namespace libtorrent
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void inc_stats_counter(int c, int value = 1);
|
||||||
|
|
||||||
// initialize the torrent_state structure passed to policy
|
// initialize the torrent_state structure passed to policy
|
||||||
// member functions. Don't forget to also call peers_erased()
|
// member functions. Don't forget to also call peers_erased()
|
||||||
// on the erased member after the policy call
|
// on the erased member after the policy call
|
||||||
|
|
|
@ -88,6 +88,7 @@ namespace libtorrent
|
||||||
web_connection_base(
|
web_connection_base(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
|
|
|
@ -77,6 +77,7 @@ namespace libtorrent
|
||||||
web_peer_connection(
|
web_peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
|
|
|
@ -98,6 +98,7 @@ namespace libtorrent
|
||||||
bt_peer_connection::bt_peer_connection(
|
bt_peer_connection::bt_peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, shared_ptr<socket_type> s
|
, shared_ptr<socket_type> s
|
||||||
|
@ -105,10 +106,9 @@ namespace libtorrent
|
||||||
, torrent_peer* peerinfo
|
, torrent_peer* peerinfo
|
||||||
, peer_id const& pid
|
, peer_id const& pid
|
||||||
, boost::weak_ptr<torrent> tor)
|
, boost::weak_ptr<torrent> tor)
|
||||||
// if tor is set, this is an outgoing connection
|
: peer_connection(ses, sett, stats_counters, allocator, disk_thread
|
||||||
: peer_connection(ses, sett, allocator, disk_thread
|
|
||||||
, ses.get_io_service()
|
, ses.get_io_service()
|
||||||
, tor, s, remote, peerinfo, tor.lock().get())
|
, tor, s, remote, peerinfo)
|
||||||
, m_state(read_protocol_identifier)
|
, m_state(read_protocol_identifier)
|
||||||
, m_supports_extensions(false)
|
, m_supports_extensions(false)
|
||||||
, m_supports_dht_port(false)
|
, m_supports_dht_port(false)
|
||||||
|
@ -283,7 +283,7 @@ namespace libtorrent
|
||||||
detail::write_uint16(listen_port, ptr);
|
detail::write_uint16(listen_port, ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_dht_port);
|
stats_counters().inc_stats_counter(counters::num_outgoing_dht_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_have_all()
|
void bt_peer_connection::write_have_all()
|
||||||
|
@ -297,7 +297,7 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1, msg_have_all};
|
char msg[] = {0,0,0,1, msg_have_all};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_have_all);
|
stats_counters().inc_stats_counter(counters::num_outgoing_have_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_have_none()
|
void bt_peer_connection::write_have_none()
|
||||||
|
@ -311,14 +311,14 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1, msg_have_none};
|
char msg[] = {0,0,0,1, msg_have_none};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_have_none);
|
stats_counters().inc_stats_counter(counters::num_outgoing_have_none);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_reject_request(peer_request const& r)
|
void bt_peer_connection::write_reject_request(peer_request const& r)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::piece_rejects);
|
stats_counters().inc_stats_counter(counters::piece_rejects);
|
||||||
|
|
||||||
if (!m_supports_fast) return;
|
if (!m_supports_fast) return;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ namespace libtorrent
|
||||||
detail::write_int32(r.length, ptr); // length
|
detail::write_int32(r.length, ptr); // length
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_reject);
|
stats_counters().inc_stats_counter(counters::num_outgoing_reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_allow_fast(int piece)
|
void bt_peer_connection::write_allow_fast(int piece)
|
||||||
|
@ -353,7 +353,7 @@ namespace libtorrent
|
||||||
detail::write_int32(piece, ptr);
|
detail::write_int32(piece, ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_allowed_fast);
|
stats_counters().inc_stats_counter(counters::num_outgoing_allowed_fast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_suggest(int piece)
|
void bt_peer_connection::write_suggest(int piece)
|
||||||
|
@ -378,7 +378,7 @@ namespace libtorrent
|
||||||
detail::write_int32(piece, ptr);
|
detail::write_int32(piece, ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_suggest);
|
stats_counters().inc_stats_counter(counters::num_outgoing_suggest);
|
||||||
}
|
}
|
||||||
|
|
||||||
char random_byte()
|
char random_byte()
|
||||||
|
@ -1664,7 +1664,7 @@ namespace libtorrent
|
||||||
|
|
||||||
send_buffer(buf, ptr - buf);
|
send_buffer(buf, ptr - buf);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
}
|
}
|
||||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
|
@ -1892,7 +1892,7 @@ namespace libtorrent
|
||||||
&& !t->share_mode())
|
&& !t->share_mode())
|
||||||
disconnect(errors::upload_upload_connection, op_bittorrent);
|
disconnect(errors::upload_upload_connection, op_bittorrent);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_incoming_ext_handshake);
|
stats_counters().inc_stats_counter(counters::num_incoming_ext_handshake);
|
||||||
}
|
}
|
||||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
|
@ -1972,7 +1972,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
TORRENT_ASSERT(false);
|
TORRENT_ASSERT(false);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counter);
|
stats_counters().inc_stats_counter(counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return finished;
|
return finished;
|
||||||
|
@ -2008,7 +2008,7 @@ namespace libtorrent
|
||||||
detail::write_uint8(t->is_upload_only() && !t->super_seeding(), ptr);
|
detail::write_uint8(t->is_upload_only() && !t->super_seeding(), ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_share_mode()
|
void bt_peer_connection::write_share_mode()
|
||||||
|
@ -2024,7 +2024,7 @@ namespace libtorrent
|
||||||
detail::write_uint8(t->share_mode(), ptr);
|
detail::write_uint8(t->share_mode(), ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2058,7 +2058,7 @@ namespace libtorrent
|
||||||
detail::write_int32(r.length, ptr); // length
|
detail::write_int32(r.length, ptr); // length
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_cancel);
|
stats_counters().inc_stats_counter(counters::num_outgoing_cancel);
|
||||||
|
|
||||||
if (!m_supports_fast)
|
if (!m_supports_fast)
|
||||||
incoming_reject_request(r);
|
incoming_reject_request(r);
|
||||||
|
@ -2079,7 +2079,7 @@ namespace libtorrent
|
||||||
detail::write_int32(r.length, ptr); // length
|
detail::write_int32(r.length, ptr); // length
|
||||||
send_buffer(msg, sizeof(msg), message_type_request);
|
send_buffer(msg, sizeof(msg), message_type_request);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_request);
|
stats_counters().inc_stats_counter(counters::num_outgoing_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_bitfield()
|
void bt_peer_connection::write_bitfield()
|
||||||
|
@ -2210,7 +2210,7 @@ namespace libtorrent
|
||||||
|
|
||||||
send_buffer(msg, packet_size);
|
send_buffer(msg, packet_size);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_bitfield);
|
stats_counters().inc_stats_counter(counters::num_outgoing_bitfield);
|
||||||
|
|
||||||
if (num_lazy_pieces > 0)
|
if (num_lazy_pieces > 0)
|
||||||
{
|
{
|
||||||
|
@ -2342,7 +2342,7 @@ namespace libtorrent
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
send_buffer(&dict_msg[0], dict_msg.size());
|
send_buffer(&dict_msg[0], dict_msg.size());
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_ext_handshake);
|
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
|
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
|
||||||
|
@ -2360,7 +2360,7 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1,msg_choke};
|
char msg[] = {0,0,0,1,msg_choke};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_choke);
|
stats_counters().inc_stats_counter(counters::num_outgoing_choke);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_unchoke()
|
void bt_peer_connection::write_unchoke()
|
||||||
|
@ -2372,7 +2372,7 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1,msg_unchoke};
|
char msg[] = {0,0,0,1,msg_unchoke};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_unchoke);
|
stats_counters().inc_stats_counter(counters::num_outgoing_unchoke);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (extension_list_t::iterator i = m_extensions.begin()
|
||||||
|
@ -2392,7 +2392,7 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1,msg_interested};
|
char msg[] = {0,0,0,1,msg_interested};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_interested);
|
stats_counters().inc_stats_counter(counters::num_outgoing_interested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_not_interested()
|
void bt_peer_connection::write_not_interested()
|
||||||
|
@ -2404,7 +2404,7 @@ namespace libtorrent
|
||||||
char msg[] = {0,0,0,1,msg_not_interested};
|
char msg[] = {0,0,0,1,msg_not_interested};
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_not_interested);
|
stats_counters().inc_stats_counter(counters::num_outgoing_not_interested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_have(int index)
|
void bt_peer_connection::write_have(int index)
|
||||||
|
@ -2420,7 +2420,7 @@ namespace libtorrent
|
||||||
detail::write_int32(index, ptr);
|
detail::write_int32(index, ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_have);
|
stats_counters().inc_stats_counter(counters::num_outgoing_have);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_dont_have(int index)
|
void bt_peer_connection::write_dont_have(int index)
|
||||||
|
@ -2442,7 +2442,7 @@ namespace libtorrent
|
||||||
detail::write_int32(index, ptr);
|
detail::write_int32(index, ptr);
|
||||||
send_buffer(msg, sizeof(msg));
|
send_buffer(msg, sizeof(msg));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2532,7 +2532,7 @@ namespace libtorrent
|
||||||
m_payloads.push_back(range(send_buffer_size() - r.length, r.length));
|
m_payloads.push_back(range(send_buffer_size() - r.length, r.length));
|
||||||
setup_send();
|
setup_send();
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_outgoing_piece);
|
stats_counters().inc_stats_counter(counters::num_outgoing_piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
|
@ -55,12 +55,13 @@ namespace libtorrent
|
||||||
http_seed_connection::http_seed_connection(
|
http_seed_connection::http_seed_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
, boost::shared_ptr<socket_type> s
|
, boost::shared_ptr<socket_type> s
|
||||||
, web_seed_entry& web)
|
, web_seed_entry& web)
|
||||||
: web_connection_base(ses, sett, allocator, disk_thread
|
: web_connection_base(ses, sett, stats_counters, allocator, disk_thread
|
||||||
, t, s, web)
|
, t, s, web)
|
||||||
, m_url(web.url)
|
, m_url(web.url)
|
||||||
, m_response_left(0)
|
, m_response_left(0)
|
||||||
|
|
|
@ -128,17 +128,18 @@ namespace libtorrent
|
||||||
peer_connection::peer_connection(
|
peer_connection::peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, io_service& ios
|
, io_service& ios
|
||||||
, boost::weak_ptr<torrent> tor
|
, boost::weak_ptr<torrent> tor
|
||||||
, shared_ptr<socket_type> s
|
, shared_ptr<socket_type> s
|
||||||
, tcp::endpoint const& endp
|
, tcp::endpoint const& endp
|
||||||
, torrent_peer* peerinfo
|
, torrent_peer* peerinfo)
|
||||||
, bool outgoing)
|
: peer_connection_hot_members(tor, ses, sett)
|
||||||
: peer_connection_hot_members(tor, ses, sett, outgoing)
|
|
||||||
, m_socket(s)
|
, m_socket(s)
|
||||||
, m_peer_info(peerinfo)
|
, m_peer_info(peerinfo)
|
||||||
|
, m_counters(stats_counters)
|
||||||
, m_num_pieces(0)
|
, m_num_pieces(0)
|
||||||
, m_rtt(0)
|
, m_rtt(0)
|
||||||
, m_recv_start(0)
|
, m_recv_start(0)
|
||||||
|
@ -188,12 +189,12 @@ namespace libtorrent
|
||||||
, m_prefer_whole_pieces(0)
|
, m_prefer_whole_pieces(0)
|
||||||
, m_disk_read_failures(0)
|
, m_disk_read_failures(0)
|
||||||
, m_outstanding_piece_verification(0)
|
, m_outstanding_piece_verification(0)
|
||||||
, m_outgoing(outgoing)
|
, m_outgoing(!tor.expired())
|
||||||
, m_received_listen_port(false)
|
, m_received_listen_port(false)
|
||||||
, m_fast_reconnect(false)
|
, m_fast_reconnect(false)
|
||||||
, m_failed(false)
|
, m_failed(false)
|
||||||
, m_connected(!outgoing)
|
, m_connected(tor.expired())
|
||||||
, m_queued(outgoing)
|
, m_queued(!tor.expired())
|
||||||
, m_request_large_blocks(false)
|
, m_request_large_blocks(false)
|
||||||
, m_share_mode(false)
|
, m_share_mode(false)
|
||||||
, m_upload_only(false)
|
, m_upload_only(false)
|
||||||
|
@ -218,12 +219,12 @@ namespace libtorrent
|
||||||
, m_socket_is_writing(false)
|
, m_socket_is_writing(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_tcp_peers + m_socket->type() - 1);
|
m_counters.inc_stats_counter(counters::num_tcp_peers + m_socket->type() - 1);
|
||||||
|
|
||||||
if (m_connected)
|
if (m_connected)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_connected);
|
m_counters.inc_stats_counter(counters::num_peers_connected);
|
||||||
else if (m_connecting)
|
else if (m_connecting)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open);
|
m_counters.inc_stats_counter(counters::num_peers_half_open);
|
||||||
|
|
||||||
m_superseed_piece[0] = -1;
|
m_superseed_piece[0] = -1;
|
||||||
m_superseed_piece[1] = -1;
|
m_superseed_piece[1] = -1;
|
||||||
|
@ -878,7 +879,7 @@ namespace libtorrent
|
||||||
|
|
||||||
peer_connection::~peer_connection()
|
peer_connection::~peer_connection()
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_tcp_peers + m_socket->type() - 1, -1);
|
m_counters.inc_stats_counter(counters::num_tcp_peers + m_socket->type() - 1, -1);
|
||||||
|
|
||||||
TORRENT_ASSERT(!m_queued_for_connection);
|
TORRENT_ASSERT(!m_queued_for_connection);
|
||||||
// INVARIANT_CHECK;
|
// INVARIANT_CHECK;
|
||||||
|
@ -899,18 +900,18 @@ namespace libtorrent
|
||||||
set_endgame(false);
|
set_endgame(false);
|
||||||
|
|
||||||
if (m_interesting)
|
if (m_interesting)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_interested, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_interested, -1);
|
||||||
if (m_peer_interested)
|
if (m_peer_interested)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_interested, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_interested, -1);
|
||||||
if (!m_choked)
|
if (!m_choked)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_unchoked, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_unchoked, -1);
|
||||||
if (!m_peer_choked)
|
if (!m_peer_choked)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_unchoked, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_unchoked, -1);
|
||||||
if (m_connected)
|
if (m_connected)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_connected, -1);
|
m_counters.inc_stats_counter(counters::num_peers_connected, -1);
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
if (!m_download_queue.empty())
|
if (!m_download_queue.empty())
|
||||||
m_ses.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();
|
||||||
|
@ -922,7 +923,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(!m_connecting);
|
TORRENT_ASSERT(!m_connecting);
|
||||||
if (m_connecting)
|
if (m_connecting)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open, -1);
|
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||||
if (t) t->dec_num_connecting();
|
if (t) t->dec_num_connecting();
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
}
|
}
|
||||||
|
@ -1423,9 +1424,9 @@ namespace libtorrent
|
||||||
if (m_endgame_mode == b) return;
|
if (m_endgame_mode == b) return;
|
||||||
m_endgame_mode = b;
|
m_endgame_mode = b;
|
||||||
if (m_endgame_mode)
|
if (m_endgame_mode)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_end_game);
|
m_counters.inc_stats_counter(counters::num_peers_end_game);
|
||||||
else
|
else
|
||||||
m_ses.inc_stats_counter(counters::num_peers_end_game, -1);
|
m_counters.inc_stats_counter(counters::num_peers_end_game, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void peer_connection::incoming_choke()
|
void peer_connection::incoming_choke()
|
||||||
|
@ -1445,7 +1446,7 @@ namespace libtorrent
|
||||||
peer_log("<== CHOKE");
|
peer_log("<== CHOKE");
|
||||||
#endif
|
#endif
|
||||||
if (m_peer_choked == false)
|
if (m_peer_choked == false)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_unchoked, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_unchoked, -1);
|
||||||
|
|
||||||
m_peer_choked = true;
|
m_peer_choked = true;
|
||||||
set_endgame(false);
|
set_endgame(false);
|
||||||
|
@ -1528,7 +1529,7 @@ namespace libtorrent
|
||||||
if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
|
if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
|
||||||
|
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
||||||
|
|
||||||
// if the peer is in parole mode, keep the request
|
// if the peer is in parole mode, keep the request
|
||||||
if (peer_info_struct() && peer_info_struct()->on_parole)
|
if (peer_info_struct() && peer_info_struct()->on_parole)
|
||||||
|
@ -1573,7 +1574,7 @@ namespace libtorrent
|
||||||
if (m_request_queue.empty() && m_download_queue.size() < 2)
|
if (m_request_queue.empty() && m_download_queue.size() < 2)
|
||||||
{
|
{
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::reject_piece_picks);
|
m_counters.inc_stats_counter(counters::reject_piece_picks);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1664,7 +1665,7 @@ namespace libtorrent
|
||||||
peer_log("<== UNCHOKE");
|
peer_log("<== UNCHOKE");
|
||||||
#endif
|
#endif
|
||||||
if (m_peer_choked)
|
if (m_peer_choked)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_unchoked);
|
m_counters.inc_stats_counter(counters::num_peers_down_unchoked);
|
||||||
|
|
||||||
m_peer_choked = false;
|
m_peer_choked = false;
|
||||||
m_last_unchoked = time_now();
|
m_last_unchoked = time_now();
|
||||||
|
@ -1673,7 +1674,7 @@ namespace libtorrent
|
||||||
if (is_interesting())
|
if (is_interesting())
|
||||||
{
|
{
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::unchoke_piece_picks);
|
m_counters.inc_stats_counter(counters::unchoke_piece_picks);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1701,7 +1702,7 @@ namespace libtorrent
|
||||||
peer_log("<== INTERESTED");
|
peer_log("<== INTERESTED");
|
||||||
#endif
|
#endif
|
||||||
if (m_peer_interested == false)
|
if (m_peer_interested == false)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_interested);
|
m_counters.inc_stats_counter(counters::num_peers_up_interested);
|
||||||
|
|
||||||
m_peer_interested = true;
|
m_peer_interested = true;
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -1796,7 +1797,7 @@ namespace libtorrent
|
||||||
peer_log("<== NOT_INTERESTED");
|
peer_log("<== NOT_INTERESTED");
|
||||||
#endif
|
#endif
|
||||||
if (m_peer_interested)
|
if (m_peer_interested)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_interested, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_interested, -1);
|
||||||
|
|
||||||
m_peer_interested = false;
|
m_peer_interested = false;
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -2240,7 +2241,7 @@ namespace libtorrent
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::piece_requests);
|
m_counters.inc_stats_counter(counters::piece_requests);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("<== REQUEST [ piece: %d s: %x l: %x ]"
|
peer_log("<== REQUEST [ piece: %d s: %x l: %x ]"
|
||||||
|
@ -2250,7 +2251,7 @@ namespace libtorrent
|
||||||
if (t->super_seeding()
|
if (t->super_seeding()
|
||||||
&& !super_seeded_piece(r.piece))
|
&& !super_seeded_piece(r.piece))
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::invalid_piece_requests);
|
m_counters.inc_stats_counter(counters::invalid_piece_requests);
|
||||||
++m_num_invalid_requests;
|
++m_num_invalid_requests;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
peer_log("*** INVALID_REQUEST [ piece not superseeded "
|
peer_log("*** INVALID_REQUEST [ piece not superseeded "
|
||||||
|
@ -2289,7 +2290,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!t->valid_metadata())
|
if (!t->valid_metadata())
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::invalid_piece_requests);
|
m_counters.inc_stats_counter(counters::invalid_piece_requests);
|
||||||
// if we don't have valid metadata yet,
|
// if we don't have valid metadata yet,
|
||||||
// we shouldn't get a request
|
// we shouldn't get a request
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
|
@ -2303,7 +2304,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (int(m_requests.size()) > m_settings.get_int(settings_pack::max_allowed_in_request_queue))
|
if (int(m_requests.size()) > m_settings.get_int(settings_pack::max_allowed_in_request_queue))
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::max_piece_requests);
|
m_counters.inc_stats_counter(counters::max_piece_requests);
|
||||||
// don't allow clients to abuse our
|
// don't allow clients to abuse our
|
||||||
// memory consumption.
|
// memory consumption.
|
||||||
// ignore requests if the client
|
// ignore requests if the client
|
||||||
|
@ -2338,7 +2339,7 @@ namespace libtorrent
|
||||||
|| !m_peer_interested
|
|| !m_peer_interested
|
||||||
|| r.length > t->block_size())
|
|| r.length > t->block_size())
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::invalid_piece_requests);
|
m_counters.inc_stats_counter(counters::invalid_piece_requests);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
peer_log("*** INVALID_REQUEST [ "
|
peer_log("*** INVALID_REQUEST [ "
|
||||||
|
@ -2401,7 +2402,7 @@ namespace libtorrent
|
||||||
peer_log(" ==> REJECT_PIECE [ piece: %d | s: %d | l: %d ] peer choked"
|
peer_log(" ==> REJECT_PIECE [ piece: %d | s: %d | l: %d ] peer choked"
|
||||||
, r.piece, r.start, r.length);
|
, r.piece, r.start, r.length);
|
||||||
#endif
|
#endif
|
||||||
m_ses.inc_stats_counter(counters::choked_piece_requests);
|
m_counters.inc_stats_counter(counters::choked_piece_requests);
|
||||||
write_reject_request(r);
|
write_reject_request(r);
|
||||||
|
|
||||||
// allow peers to send request up to 2 seconds after getting choked,
|
// allow peers to send request up to 2 seconds after getting choked,
|
||||||
|
@ -2420,7 +2421,7 @@ namespace libtorrent
|
||||||
++m_accept_fast_piece_cnt[fast_idx];
|
++m_accept_fast_piece_cnt[fast_idx];
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_requests);
|
m_counters.inc_stats_counter(counters::num_peers_up_requests);
|
||||||
|
|
||||||
m_requests.push_back(r);
|
m_requests.push_back(r);
|
||||||
#ifdef TORRENT_REQUEST_LOGGING
|
#ifdef TORRENT_REQUEST_LOGGING
|
||||||
|
@ -2445,7 +2446,7 @@ namespace libtorrent
|
||||||
i = m_requests.erase(i);
|
i = m_requests.erase(i);
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_requests, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2522,7 +2523,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests);
|
||||||
|
|
||||||
m_download_queue.insert(m_download_queue.begin(), b);
|
m_download_queue.insert(m_download_queue.begin(), b);
|
||||||
if (!in_req_queue)
|
if (!in_req_queue)
|
||||||
|
@ -2591,7 +2592,7 @@ namespace libtorrent
|
||||||
if (exceeded)
|
if (exceeded)
|
||||||
{
|
{
|
||||||
if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0)
|
if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk);
|
||||||
m_channel_state[download_channel] |= peer_info::bw_disk;
|
m_channel_state[download_channel] |= peer_info::bw_disk;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("*** exceeded disk buffer watermark");
|
peer_log("*** exceeded disk buffer watermark");
|
||||||
|
@ -2688,7 +2689,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_download_queue.erase(m_download_queue.begin());
|
m_download_queue.erase(m_download_queue.begin());
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
||||||
}
|
}
|
||||||
t->add_redundant_bytes(p.length, torrent::piece_seed);
|
t->add_redundant_bytes(p.length, torrent::piece_seed);
|
||||||
return;
|
return;
|
||||||
|
@ -2754,7 +2755,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_download_queue.erase(b);
|
m_download_queue.erase(b);
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
||||||
|
|
||||||
m_timeout_extend = 0;
|
m_timeout_extend = 0;
|
||||||
|
|
||||||
|
@ -2764,7 +2765,7 @@ namespace libtorrent
|
||||||
m_requested = now;
|
m_requested = now;
|
||||||
|
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::incoming_redundant_piece_picks);
|
m_counters.inc_stats_counter(counters::incoming_redundant_piece_picks);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2792,7 +2793,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
m_download_queue.erase(b);
|
m_download_queue.erase(b);
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
|
||||||
|
|
||||||
if (t->is_deleted()) return;
|
if (t->is_deleted()) return;
|
||||||
|
|
||||||
|
@ -2806,7 +2807,7 @@ namespace libtorrent
|
||||||
, boost::bind(&peer_connection::on_disk_write_complete
|
, boost::bind(&peer_connection::on_disk_write_complete
|
||||||
, self(), _1, p, t));
|
, self(), _1, p, t));
|
||||||
|
|
||||||
boost::uint64_t write_queue_size = m_ses.inc_stats_counter(
|
boost::uint64_t write_queue_size = m_counters.inc_stats_counter(
|
||||||
counters::queued_write_bytes, p.length);
|
counters::queued_write_bytes, p.length);
|
||||||
m_outstanding_writing_bytes += p.length;
|
m_outstanding_writing_bytes += p.length;
|
||||||
|
|
||||||
|
@ -2909,7 +2910,7 @@ namespace libtorrent
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::incoming_piece_picks);
|
m_counters.inc_stats_counter(counters::incoming_piece_picks);
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2925,7 +2926,7 @@ namespace libtorrent
|
||||||
, j->ret, p.piece, p.start, p.length, j->error.ec.message().c_str());
|
, j->ret, p.piece, p.start, p.length, j->error.ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::queued_write_bytes, -p.length);
|
m_counters.inc_stats_counter(counters::queued_write_bytes, -p.length);
|
||||||
m_outstanding_writing_bytes -= p.length;
|
m_outstanding_writing_bytes -= p.length;
|
||||||
|
|
||||||
TORRENT_ASSERT(m_outstanding_writing_bytes >= 0);
|
TORRENT_ASSERT(m_outstanding_writing_bytes >= 0);
|
||||||
|
@ -3033,11 +3034,11 @@ namespace libtorrent
|
||||||
|
|
||||||
if (i != m_requests.end())
|
if (i != m_requests.end())
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::cancelled_piece_requests);
|
m_counters.inc_stats_counter(counters::cancelled_piece_requests);
|
||||||
m_requests.erase(i);
|
m_requests.erase(i);
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_requests, -1);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("==> REJECT_PIECE [ piece: %d s: %x l: %x ] cancelled"
|
peer_log("==> REJECT_PIECE [ piece: %d s: %x l: %x ] cancelled"
|
||||||
|
@ -3577,7 +3578,7 @@ namespace libtorrent
|
||||||
peer_log("==> CHOKE");
|
peer_log("==> CHOKE");
|
||||||
#endif
|
#endif
|
||||||
write_choke();
|
write_choke();
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_unchoked, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_unchoked, -1);
|
||||||
m_choked = true;
|
m_choked = true;
|
||||||
|
|
||||||
m_last_choke = time_now();
|
m_last_choke = time_now();
|
||||||
|
@ -3595,7 +3596,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
peer_request const& r = *i;
|
peer_request const& r = *i;
|
||||||
m_ses.inc_stats_counter(counters::choked_piece_requests);
|
m_counters.inc_stats_counter(counters::choked_piece_requests);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ] choking"
|
peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ] choking"
|
||||||
, r.piece , r.start , r.length);
|
, r.piece , r.start , r.length);
|
||||||
|
@ -3604,7 +3605,7 @@ namespace libtorrent
|
||||||
i = m_requests.erase(i);
|
i = m_requests.erase(i);
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_requests, -1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3637,7 +3638,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_last_unchoke = time_now();
|
m_last_unchoke = time_now();
|
||||||
write_unchoke();
|
write_unchoke();
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_unchoked);
|
m_counters.inc_stats_counter(counters::num_peers_up_unchoked);
|
||||||
m_choked = false;
|
m_choked = false;
|
||||||
|
|
||||||
m_uploaded_at_last_unchoke = m_statistics.total_payload_upload();
|
m_uploaded_at_last_unchoke = m_statistics.total_payload_upload();
|
||||||
|
@ -3654,7 +3655,7 @@ namespace libtorrent
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
if (!t->ready_for_connections()) return;
|
if (!t->ready_for_connections()) return;
|
||||||
m_interesting = true;
|
m_interesting = true;
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_interested);
|
m_counters.inc_stats_counter(counters::num_peers_down_interested);
|
||||||
write_interested();
|
write_interested();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
|
@ -3677,7 +3678,7 @@ namespace libtorrent
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
if (!t->ready_for_connections()) return;
|
if (!t->ready_for_connections()) return;
|
||||||
m_interesting = false;
|
m_interesting = false;
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_interested, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_interested, -1);
|
||||||
|
|
||||||
disconnect_if_redundant();
|
disconnect_if_redundant();
|
||||||
if (m_disconnecting) return;
|
if (m_disconnecting) return;
|
||||||
|
@ -3789,7 +3790,7 @@ namespace libtorrent
|
||||||
r.length = block_size;
|
r.length = block_size;
|
||||||
|
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests);
|
||||||
|
|
||||||
TORRENT_ASSERT(verify_piece(t->to_req(block.block)));
|
TORRENT_ASSERT(verify_piece(t->to_req(block.block)));
|
||||||
m_download_queue.push_back(block);
|
m_download_queue.push_back(block);
|
||||||
|
@ -3825,7 +3826,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(verify_piece(t->to_req(block.block)));
|
TORRENT_ASSERT(verify_piece(t->to_req(block.block)));
|
||||||
|
|
||||||
if (m_download_queue.empty())
|
if (m_download_queue.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_requests);
|
m_counters.inc_stats_counter(counters::num_peers_down_requests);
|
||||||
|
|
||||||
m_download_queue.push_back(block);
|
m_download_queue.push_back(block);
|
||||||
if (m_queued_time_critical) --m_queued_time_critical;
|
if (m_queued_time_critical) --m_queued_time_critical;
|
||||||
|
@ -3913,13 +3914,13 @@ namespace libtorrent
|
||||||
m_ses.session_log(" CONNECTION FAILED: %s", print_endpoint(m_remote).c_str());
|
m_ses.session_log(" CONNECTION FAILED: %s", print_endpoint(m_remote).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::connect_timeouts);
|
m_counters.inc_stats_counter(counters::connect_timeouts);
|
||||||
|
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
TORRENT_ASSERT(!m_connecting || t);
|
TORRENT_ASSERT(!m_connecting || t);
|
||||||
if (m_connecting)
|
if (m_connecting)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open, -1);
|
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||||
if (t) t->dec_num_connecting();
|
if (t) t->dec_num_connecting();
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
}
|
}
|
||||||
|
@ -4015,7 +4016,7 @@ namespace libtorrent
|
||||||
if (error > 0) m_failed = true;
|
if (error > 0) m_failed = true;
|
||||||
|
|
||||||
if (m_connected)
|
if (m_connected)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_connected, -1);
|
m_counters.inc_stats_counter(counters::num_peers_connected, -1);
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
|
|
||||||
// for incoming connections, we get invalid argument errors
|
// for incoming connections, we get invalid argument errors
|
||||||
|
@ -4025,61 +4026,61 @@ namespace libtorrent
|
||||||
// for outgoing connections however, why would we get this?
|
// for outgoing connections however, why would we get this?
|
||||||
// TORRENT_ASSERT(ec != error::invalid_argument || !m_outgoing);
|
// TORRENT_ASSERT(ec != error::invalid_argument || !m_outgoing);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::disconnected_peers);
|
m_counters.inc_stats_counter(counters::disconnected_peers);
|
||||||
if (error == 2) m_ses.inc_stats_counter(counters::error_peers);
|
if (error == 2) m_counters.inc_stats_counter(counters::error_peers);
|
||||||
if (ec == error::connection_reset) m_ses.inc_stats_counter(counters::connreset_peers);
|
if (ec == error::connection_reset) m_counters.inc_stats_counter(counters::connreset_peers);
|
||||||
else if (ec == error::eof) m_ses.inc_stats_counter(counters::eof_peers);
|
else if (ec == error::eof) m_counters.inc_stats_counter(counters::eof_peers);
|
||||||
else if (ec == error::connection_refused) m_ses.inc_stats_counter(counters::connrefused_peers);
|
else if (ec == error::connection_refused) m_counters.inc_stats_counter(counters::connrefused_peers);
|
||||||
else if (ec == error::connection_aborted) m_ses.inc_stats_counter(counters::connaborted_peers);
|
else if (ec == error::connection_aborted) m_counters.inc_stats_counter(counters::connaborted_peers);
|
||||||
else if (ec == error::no_permission) m_ses.inc_stats_counter(counters::perm_peers);
|
else if (ec == error::no_permission) m_counters.inc_stats_counter(counters::perm_peers);
|
||||||
else if (ec == error::no_buffer_space) m_ses.inc_stats_counter(counters::buffer_peers);
|
else if (ec == error::no_buffer_space) m_counters.inc_stats_counter(counters::buffer_peers);
|
||||||
else if (ec == error::host_unreachable) m_ses.inc_stats_counter(counters::unreachable_peers);
|
else if (ec == error::host_unreachable) m_counters.inc_stats_counter(counters::unreachable_peers);
|
||||||
else if (ec == error::broken_pipe) m_ses.inc_stats_counter(counters::broken_pipe_peers);
|
else if (ec == error::broken_pipe) m_counters.inc_stats_counter(counters::broken_pipe_peers);
|
||||||
else if (ec == error::address_in_use) m_ses.inc_stats_counter(counters::addrinuse_peers);
|
else if (ec == error::address_in_use) m_counters.inc_stats_counter(counters::addrinuse_peers);
|
||||||
else if (ec == error::access_denied) m_ses.inc_stats_counter(counters::no_access_peers);
|
else if (ec == error::access_denied) m_counters.inc_stats_counter(counters::no_access_peers);
|
||||||
else if (ec == error::invalid_argument) m_ses.inc_stats_counter(counters::invalid_arg_peers);
|
else if (ec == error::invalid_argument) m_counters.inc_stats_counter(counters::invalid_arg_peers);
|
||||||
else if (ec == error::operation_aborted) m_ses.inc_stats_counter(counters::aborted_peers);
|
else if (ec == error::operation_aborted) m_counters.inc_stats_counter(counters::aborted_peers);
|
||||||
else if (ec == error_code(errors::upload_upload_connection)
|
else if (ec == error_code(errors::upload_upload_connection)
|
||||||
|| ec == error_code(errors::uninteresting_upload_peer)
|
|| ec == error_code(errors::uninteresting_upload_peer)
|
||||||
|| ec == error_code(errors::torrent_aborted)
|
|| ec == error_code(errors::torrent_aborted)
|
||||||
|| ec == error_code(errors::self_connection)
|
|| ec == error_code(errors::self_connection)
|
||||||
|| ec == error_code(errors::torrent_paused))
|
|| ec == error_code(errors::torrent_paused))
|
||||||
m_ses.inc_stats_counter(counters::uninteresting_peers);
|
m_counters.inc_stats_counter(counters::uninteresting_peers);
|
||||||
|
|
||||||
if (ec == error_code(errors::timed_out)
|
if (ec == error_code(errors::timed_out)
|
||||||
|| ec == error::timed_out)
|
|| ec == error::timed_out)
|
||||||
m_ses.inc_stats_counter(counters::transport_timeout_peers);
|
m_counters.inc_stats_counter(counters::transport_timeout_peers);
|
||||||
|
|
||||||
if (ec == error_code(errors::timed_out_inactivity)
|
if (ec == error_code(errors::timed_out_inactivity)
|
||||||
|| ec == error_code(errors::timed_out_no_request)
|
|| ec == error_code(errors::timed_out_no_request)
|
||||||
|| ec == error_code(errors::timed_out_no_interest))
|
|| ec == error_code(errors::timed_out_no_interest))
|
||||||
m_ses.inc_stats_counter(counters::timeout_peers);
|
m_counters.inc_stats_counter(counters::timeout_peers);
|
||||||
|
|
||||||
if (ec == error_code(errors::no_memory))
|
if (ec == error_code(errors::no_memory))
|
||||||
m_ses.inc_stats_counter(counters::no_memory_peers);
|
m_counters.inc_stats_counter(counters::no_memory_peers);
|
||||||
|
|
||||||
if (ec == error_code(errors::too_many_connections))
|
if (ec == error_code(errors::too_many_connections))
|
||||||
m_ses.inc_stats_counter(counters::too_many_peers);
|
m_counters.inc_stats_counter(counters::too_many_peers);
|
||||||
|
|
||||||
if (ec == error_code(errors::timed_out_no_handshake))
|
if (ec == error_code(errors::timed_out_no_handshake))
|
||||||
m_ses.inc_stats_counter(counters::connect_timeouts);
|
m_counters.inc_stats_counter(counters::connect_timeouts);
|
||||||
|
|
||||||
if (error > 0)
|
if (error > 0)
|
||||||
{
|
{
|
||||||
if (is_utp(*m_socket)) m_ses.inc_stats_counter(counters::error_utp_peers);
|
if (is_utp(*m_socket)) m_counters.inc_stats_counter(counters::error_utp_peers);
|
||||||
else m_ses.inc_stats_counter(counters::error_tcp_peers);
|
else m_counters.inc_stats_counter(counters::error_tcp_peers);
|
||||||
|
|
||||||
if (m_outgoing) m_ses.inc_stats_counter(counters::error_outgoing_peers);
|
if (m_outgoing) m_counters.inc_stats_counter(counters::error_outgoing_peers);
|
||||||
else m_ses.inc_stats_counter(counters::error_incoming_peers);
|
else m_counters.inc_stats_counter(counters::error_incoming_peers);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||||
if (type() == bittorrent_connection)
|
if (type() == bittorrent_connection)
|
||||||
{
|
{
|
||||||
bt_peer_connection* bt = static_cast<bt_peer_connection*>(this);
|
bt_peer_connection* bt = static_cast<bt_peer_connection*>(this);
|
||||||
if (bt->supports_encryption()) m_ses.inc_stats_counter(
|
if (bt->supports_encryption()) m_counters.inc_stats_counter(
|
||||||
counters::error_encrypted_peers);
|
counters::error_encrypted_peers);
|
||||||
if (bt->rc4_encrypted() && bt->supports_encryption())
|
if (bt->rc4_encrypted() && bt->supports_encryption())
|
||||||
m_ses.inc_stats_counter(counters::error_rc4_peers);
|
m_counters.inc_stats_counter(counters::error_rc4_peers);
|
||||||
}
|
}
|
||||||
#endif // TORRENT_DISABLE_ENCRYPTION
|
#endif // TORRENT_DISABLE_ENCRYPTION
|
||||||
}
|
}
|
||||||
|
@ -4090,19 +4091,19 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_channel_state[upload_channel] & peer_info::bw_disk)
|
if (m_channel_state[upload_channel] & peer_info::bw_disk)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_disk, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_disk, -1);
|
||||||
m_channel_state[upload_channel] &= ~peer_info::bw_disk;
|
m_channel_state[upload_channel] &= ~peer_info::bw_disk;
|
||||||
}
|
}
|
||||||
if (m_channel_state[download_channel] & peer_info::bw_disk)
|
if (m_channel_state[download_channel] & peer_info::bw_disk)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk, -1);
|
||||||
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
if (m_connecting)
|
if (m_connecting)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open, -1);
|
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||||
if (t) t->dec_num_connecting();
|
if (t) t->dec_num_connecting();
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
}
|
}
|
||||||
|
@ -4420,7 +4421,7 @@ namespace libtorrent
|
||||||
peer_log("*** exceeded disk buffer watermark");
|
peer_log("*** exceeded disk buffer watermark");
|
||||||
#endif
|
#endif
|
||||||
if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0)
|
if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk);
|
||||||
m_channel_state[download_channel] |= peer_info::bw_disk;
|
m_channel_state[download_channel] |= peer_info::bw_disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4613,7 +4614,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t || !m_connecting);
|
TORRENT_ASSERT(t || !m_connecting);
|
||||||
if (m_connecting)
|
if (m_connecting)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open, -1);
|
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||||
if (t) t->dec_num_connecting();
|
if (t) t->dec_num_connecting();
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
}
|
}
|
||||||
|
@ -4636,7 +4637,7 @@ namespace libtorrent
|
||||||
// if we can pick a busy one
|
// if we can pick a busy one
|
||||||
m_last_request = now;
|
m_last_request = now;
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::end_game_piece_picks);
|
m_counters.inc_stats_counter(counters::end_game_piece_picks);
|
||||||
if (m_disconnecting) return;
|
if (m_disconnecting) return;
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
}
|
}
|
||||||
|
@ -4860,7 +4861,7 @@ namespace libtorrent
|
||||||
// same piece indefinitely.
|
// same piece indefinitely.
|
||||||
m_desired_queue_size = 2;
|
m_desired_queue_size = 2;
|
||||||
if (request_a_block(*t, *this))
|
if (request_a_block(*t, *this))
|
||||||
m_ses.inc_stats_counter(counters::snubbed_piece_picks);
|
m_counters.inc_stats_counter(counters::snubbed_piece_picks);
|
||||||
|
|
||||||
// the block we just picked (potentially)
|
// the block we just picked (potentially)
|
||||||
// hasn't been put in m_download_queue yet.
|
// hasn't been put in m_download_queue yet.
|
||||||
|
@ -5047,7 +5048,7 @@ namespace libtorrent
|
||||||
m_requests.erase(m_requests.begin() + i);
|
m_requests.erase(m_requests.begin() + i);
|
||||||
|
|
||||||
if (m_requests.empty())
|
if (m_requests.empty())
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_requests, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_requests, -1);
|
||||||
|
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
@ -5360,7 +5361,7 @@ namespace libtorrent
|
||||||
&& quota_left > 0)
|
&& quota_left > 0)
|
||||||
{
|
{
|
||||||
if ((m_channel_state[upload_channel] & peer_info::bw_disk) == 0)
|
if ((m_channel_state[upload_channel] & peer_info::bw_disk) == 0)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_disk);
|
m_counters.inc_stats_counter(counters::num_peers_up_disk);
|
||||||
m_channel_state[upload_channel] |= peer_info::bw_disk;
|
m_channel_state[upload_channel] |= peer_info::bw_disk;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
peer_log(">>> waiting for disk [outstanding: %d]", m_reading_bytes);
|
peer_log(">>> waiting for disk [outstanding: %d]", m_reading_bytes);
|
||||||
|
@ -5392,7 +5393,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_channel_state[upload_channel] & peer_info::bw_disk)
|
if (m_channel_state[upload_channel] & peer_info::bw_disk)
|
||||||
m_ses.inc_stats_counter(counters::num_peers_up_disk, -1);
|
m_counters.inc_stats_counter(counters::num_peers_up_disk, -1);
|
||||||
m_channel_state[upload_channel] &= ~peer_info::bw_disk;
|
m_channel_state[upload_channel] &= ~peer_info::bw_disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5474,7 +5475,7 @@ namespace libtorrent
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
peer_log("*** dropped below disk buffer watermark");
|
peer_log("*** dropped below disk buffer watermark");
|
||||||
#endif
|
#endif
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk, -1);
|
||||||
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
||||||
setup_receive(read_async);
|
setup_receive(read_async);
|
||||||
}
|
}
|
||||||
|
@ -5489,7 +5490,7 @@ namespace libtorrent
|
||||||
m_disk_recv_buffer.reset(buffer);
|
m_disk_recv_buffer.reset(buffer);
|
||||||
m_disk_recv_buffer_size = buffer_size;
|
m_disk_recv_buffer_size = buffer_size;
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk, -1);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk, -1);
|
||||||
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
m_channel_state[download_channel] &= ~peer_info::bw_disk;
|
||||||
|
|
||||||
setup_receive(read_async);
|
setup_receive(read_async);
|
||||||
|
@ -6008,7 +6009,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::on_read_counter);
|
m_counters.inc_stats_counter(counters::on_read_counter);
|
||||||
m_ses.received_buffer(bytes_transferred);
|
m_ses.received_buffer(bytes_transferred);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
|
@ -6157,7 +6158,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_disk_recv_buffer == NULL)
|
if (m_disk_recv_buffer == NULL)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_down_disk);
|
m_counters.inc_stats_counter(counters::num_peers_down_disk);
|
||||||
const_cast<peer_connection*>(this)->m_channel_state[download_channel] |= peer_info::bw_disk;
|
const_cast<peer_connection*>(this)->m_channel_state[download_channel] |= peer_info::bw_disk;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
|
@ -6309,7 +6310,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t || !m_connecting);
|
TORRENT_ASSERT(t || !m_connecting);
|
||||||
if (m_connecting)
|
if (m_connecting)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_peers_half_open, -1);
|
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||||
if (t) t->dec_num_connecting();
|
if (t) t->dec_num_connecting();
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
}
|
}
|
||||||
|
@ -6321,7 +6322,7 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_ASSERT(!m_connected);
|
TORRENT_ASSERT(!m_connected);
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
m_ses.inc_stats_counter(counters::num_peers_connected);
|
m_counters.inc_stats_counter(counters::num_peers_connected);
|
||||||
|
|
||||||
if (m_disconnecting) return;
|
if (m_disconnecting) return;
|
||||||
m_last_receive = time_now();
|
m_last_receive = time_now();
|
||||||
|
@ -6419,7 +6420,7 @@ namespace libtorrent
|
||||||
void peer_connection::on_send_data(error_code const& error
|
void peer_connection::on_send_data(error_code const& error
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::on_write_counter);
|
m_counters.inc_stats_counter(counters::on_write_counter);
|
||||||
m_ses.sent_buffer(bytes_transferred);
|
m_ses.sent_buffer(bytes_transferred);
|
||||||
TORRENT_ASSERT(m_ses.is_single_thread());
|
TORRENT_ASSERT(m_ses.is_single_thread());
|
||||||
|
|
||||||
|
|
|
@ -2046,7 +2046,7 @@ namespace aux {
|
||||||
if (m_torrent_lru.size() > loaded_limit)
|
if (m_torrent_lru.size() > loaded_limit)
|
||||||
{
|
{
|
||||||
// just evict the torrent
|
// just evict the torrent
|
||||||
inc_stats_counter(counters::torrent_evicted_counter);
|
m_stats_counters.inc_stats_counter(counters::torrent_evicted_counter);
|
||||||
TORRENT_ASSERT(t->is_pinned() == false);
|
TORRENT_ASSERT(t->is_pinned() == false);
|
||||||
t->unload();
|
t->unload();
|
||||||
m_torrent_lru.erase(t);
|
m_torrent_lru.erase(t);
|
||||||
|
@ -2090,7 +2090,7 @@ namespace aux {
|
||||||
i = (torrent*)i->next;
|
i = (torrent*)i->next;
|
||||||
if (i == NULL) break;
|
if (i == NULL) break;
|
||||||
}
|
}
|
||||||
inc_stats_counter(counters::torrent_evicted_counter);
|
m_stats_counters.inc_stats_counter(counters::torrent_evicted_counter);
|
||||||
TORRENT_ASSERT(i->is_pinned() == false);
|
TORRENT_ASSERT(i->is_pinned() == false);
|
||||||
i->unload();
|
i->unload();
|
||||||
m_torrent_lru.erase(i);
|
m_torrent_lru.erase(i);
|
||||||
|
@ -2785,7 +2785,7 @@ retry:
|
||||||
bool session_impl::incoming_packet(error_code const& ec
|
bool session_impl::incoming_packet(error_code const& ec
|
||||||
, udp::endpoint const& ep, char const* buf, int size)
|
, udp::endpoint const& ep, char const* buf, int size)
|
||||||
{
|
{
|
||||||
inc_stats_counter(counters::on_udp_counter);
|
m_stats_counters.inc_stats_counter(counters::on_udp_counter);
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
|
@ -2838,7 +2838,7 @@ retry:
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
complete_async("session_impl::on_accept_connection");
|
complete_async("session_impl::on_accept_connection");
|
||||||
#endif
|
#endif
|
||||||
inc_stats_counter(counters::on_accept_counter);
|
m_stats_counters.inc_stats_counter(counters::on_accept_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<socket_acceptor> listener = listen_socket.lock();
|
boost::shared_ptr<socket_acceptor> listener = listen_socket.lock();
|
||||||
if (!listener) return;
|
if (!listener) return;
|
||||||
|
@ -3172,7 +3172,8 @@ retry:
|
||||||
|
|
||||||
boost::shared_ptr<peer_connection> c
|
boost::shared_ptr<peer_connection> c
|
||||||
= boost::make_shared<bt_peer_connection>(boost::ref(*this), m_settings
|
= boost::make_shared<bt_peer_connection>(boost::ref(*this), m_settings
|
||||||
, boost::ref(*this), boost::ref(m_disk_thread), s, endp, (torrent_peer*)0
|
, boost::ref(m_stats_counters), boost::ref(*this)
|
||||||
|
, boost::ref(m_disk_thread), s, endp, (torrent_peer*)0
|
||||||
, get_peer_id());
|
, get_peer_id());
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
c->m_in_constructor = false;
|
c->m_in_constructor = false;
|
||||||
|
@ -3420,7 +3421,7 @@ retry:
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
complete_async("session_impl::on_tick");
|
complete_async("session_impl::on_tick");
|
||||||
#endif
|
#endif
|
||||||
inc_stats_counter(counters::on_tick_counter);
|
m_stats_counters.inc_stats_counter(counters::on_tick_counter);
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
|
@ -4584,7 +4585,7 @@ retry:
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
complete_async("session_impl::on_lsd_announce");
|
complete_async("session_impl::on_lsd_announce");
|
||||||
#endif
|
#endif
|
||||||
inc_stats_counter(counters::on_lsd_counter);
|
m_stats_counters.inc_stats_counter(counters::on_lsd_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
||||||
|
@ -5011,7 +5012,7 @@ retry:
|
||||||
--max_connections;
|
--max_connections;
|
||||||
--free_slots;
|
--free_slots;
|
||||||
steps_since_last_connect = 0;
|
steps_since_last_connect = 0;
|
||||||
inc_stats_counter(counters::connection_attempts);
|
m_stats_counters.inc_stats_counter(counters::connection_attempts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TORRENT_CATCH(std::bad_alloc&)
|
TORRENT_CATCH(std::bad_alloc&)
|
||||||
|
@ -5285,7 +5286,7 @@ retry:
|
||||||
|
|
||||||
void session_impl::do_delayed_uncork()
|
void session_impl::do_delayed_uncork()
|
||||||
{
|
{
|
||||||
inc_stats_counter(counters::on_disk_counter);
|
m_stats_counters.inc_stats_counter(counters::on_disk_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
for (std::vector<peer_connection*>::iterator i = m_delayed_uncorks.begin()
|
for (std::vector<peer_connection*>::iterator i = m_delayed_uncorks.begin()
|
||||||
, end(m_delayed_uncorks.end()); i != end; ++i)
|
, end(m_delayed_uncorks.end()); i != end; ++i)
|
||||||
|
@ -6428,7 +6429,7 @@ retry:
|
||||||
|
|
||||||
void session_impl::on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih)
|
void session_impl::on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih)
|
||||||
{
|
{
|
||||||
inc_stats_counter(counters::on_lsd_peer_counter);
|
m_stats_counters.inc_stats_counter(counters::on_lsd_peer_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
|
@ -234,9 +234,9 @@ namespace libtorrent
|
||||||
, m_use_resume_save_path(p.flags & add_torrent_params::flag_use_resume_save_path)
|
, m_use_resume_save_path(p.flags & add_torrent_params::flag_use_resume_save_path)
|
||||||
{
|
{
|
||||||
if (m_pinned)
|
if (m_pinned)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents);
|
inc_stats_counter(counters::num_pinned_torrents);
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_loaded_torrents);
|
inc_stats_counter(counters::num_loaded_torrents);
|
||||||
|
|
||||||
// if there is resume data already, we don't need to trigger the initial save
|
// if there is resume data already, we don't need to trigger the initial save
|
||||||
// resume data
|
// resume data
|
||||||
|
@ -262,7 +262,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
if (!m_apply_ip_filter)
|
if (!m_apply_ip_filter)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::non_filter_torrents);
|
inc_stats_counter(counters::non_filter_torrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p.ti || !p.ti->is_valid())
|
if (!p.ti || !p.ti->is_valid())
|
||||||
|
@ -366,19 +366,22 @@ namespace libtorrent
|
||||||
if (!valid_metadata())
|
if (!valid_metadata())
|
||||||
{
|
{
|
||||||
if (!m_pinned && m_refcount == 0)
|
if (!m_pinned && m_refcount == 0)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents);
|
inc_stats_counter(counters::num_pinned_torrents);
|
||||||
|
|
||||||
m_pinned = true;
|
m_pinned = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::num_total_pieces_added
|
inc_stats_counter(counters::num_total_pieces_added
|
||||||
, m_torrent_file->num_pieces());
|
, m_torrent_file->num_pieces());
|
||||||
}
|
}
|
||||||
|
|
||||||
update_gauge();
|
update_gauge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void torrent::inc_stats_counter(int c, int value)
|
||||||
|
{ m_ses.stats_counters().inc_stats_counter(c, value); }
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
// NON BOTTLED VERSION. SUPPORTS PROGRESS REPORTING
|
// NON BOTTLED VERSION. SUPPORTS PROGRESS REPORTING
|
||||||
|
@ -565,9 +568,9 @@ namespace libtorrent
|
||||||
if (new_gauge_state == m_current_gauge_state) return;
|
if (new_gauge_state == m_current_gauge_state) return;
|
||||||
|
|
||||||
if (m_current_gauge_state != no_gauge_state)
|
if (m_current_gauge_state != no_gauge_state)
|
||||||
m_ses.inc_stats_counter(m_current_gauge_state + counters::num_checking_torrents, -1);
|
inc_stats_counter(m_current_gauge_state + counters::num_checking_torrents, -1);
|
||||||
if (new_gauge_state != no_gauge_state)
|
if (new_gauge_state != no_gauge_state)
|
||||||
m_ses.inc_stats_counter(new_gauge_state + counters::num_checking_torrents, 1);
|
inc_stats_counter(new_gauge_state + counters::num_checking_torrents, 1);
|
||||||
|
|
||||||
m_current_gauge_state = new_gauge_state;
|
m_current_gauge_state = new_gauge_state;
|
||||||
}
|
}
|
||||||
|
@ -802,11 +805,11 @@ namespace libtorrent
|
||||||
if (b == m_apply_ip_filter) return;
|
if (b == m_apply_ip_filter) return;
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::non_filter_torrents, -1);
|
inc_stats_counter(counters::non_filter_torrents, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::non_filter_torrents);
|
inc_stats_counter(counters::non_filter_torrents);
|
||||||
}
|
}
|
||||||
m_apply_ip_filter = b;
|
m_apply_ip_filter = b;
|
||||||
ip_filter_updated();
|
ip_filter_updated();
|
||||||
|
@ -860,10 +863,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(m_refcount == 0);
|
TORRENT_ASSERT(m_refcount == 0);
|
||||||
|
|
||||||
if (m_pinned)
|
if (m_pinned)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents, -1);
|
inc_stats_counter(counters::num_pinned_torrents, -1);
|
||||||
|
|
||||||
if (is_loaded())
|
if (is_loaded())
|
||||||
m_ses.inc_stats_counter(counters::num_loaded_torrents, -1);
|
inc_stats_counter(counters::num_loaded_torrents, -1);
|
||||||
|
|
||||||
// The invariant can't be maintained here, since the torrent
|
// The invariant can't be maintained here, since the torrent
|
||||||
// is being destructed, all weak references to it have been
|
// is being destructed, all weak references to it have been
|
||||||
|
@ -1164,7 +1167,7 @@ namespace libtorrent
|
||||||
if (!m_abort)
|
if (!m_abort)
|
||||||
{
|
{
|
||||||
if (request_a_block(*this, *p))
|
if (request_a_block(*this, *p))
|
||||||
m_ses.inc_stats_counter(counters::hash_fail_piece_picks);
|
inc_stats_counter(counters::hash_fail_piece_picks);
|
||||||
p->send_block_requests();
|
p->send_block_requests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1931,7 +1934,7 @@ namespace libtorrent
|
||||||
if (m_refcount == 0)
|
if (m_refcount == 0)
|
||||||
{
|
{
|
||||||
if (!m_pinned)
|
if (!m_pinned)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents, -1);
|
inc_stats_counter(counters::num_pinned_torrents, -1);
|
||||||
|
|
||||||
if (m_should_be_loaded == false)
|
if (m_should_be_loaded == false)
|
||||||
unload();
|
unload();
|
||||||
|
@ -1944,7 +1947,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_loaded());
|
TORRENT_ASSERT(is_loaded());
|
||||||
++m_refcount;
|
++m_refcount;
|
||||||
if (!m_pinned && m_refcount == 1)
|
if (!m_pinned && m_refcount == 1)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents);
|
inc_stats_counter(counters::num_pinned_torrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::set_pinned(bool p)
|
void torrent::set_pinned(bool p)
|
||||||
|
@ -1954,7 +1957,7 @@ namespace libtorrent
|
||||||
m_pinned = p;
|
m_pinned = p;
|
||||||
|
|
||||||
if (m_refcount == 0)
|
if (m_refcount == 0)
|
||||||
m_ses.inc_stats_counter(counters::num_pinned_torrents, p ? 1 : -1);
|
inc_stats_counter(counters::num_pinned_torrents, p ? 1 : -1);
|
||||||
|
|
||||||
// if the torrent was just un-pinned, we need to insert
|
// if the torrent was just un-pinned, we need to insert
|
||||||
// it into the LRU
|
// it into the LRU
|
||||||
|
@ -1991,7 +1994,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_loaded_torrents);
|
inc_stats_counter(counters::num_loaded_torrents);
|
||||||
|
|
||||||
construct_storage();
|
construct_storage();
|
||||||
|
|
||||||
|
@ -2039,7 +2042,7 @@ namespace libtorrent
|
||||||
m_torrent_file = boost::make_shared<torrent_info>(*m_torrent_file);
|
m_torrent_file = boost::make_shared<torrent_info>(*m_torrent_file);
|
||||||
|
|
||||||
m_torrent_file->unload();
|
m_torrent_file->unload();
|
||||||
m_ses.inc_stats_counter(counters::num_loaded_torrents, -1);
|
inc_stats_counter(counters::num_loaded_torrents, -1);
|
||||||
|
|
||||||
m_storage.reset();
|
m_storage.reset();
|
||||||
|
|
||||||
|
@ -2256,7 +2259,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
need_picker();
|
need_picker();
|
||||||
m_picker->we_have(i);
|
m_picker->we_have(i);
|
||||||
m_ses.inc_stats_counter(counters::num_piece_passed);
|
inc_stats_counter(counters::num_piece_passed);
|
||||||
update_gauge();
|
update_gauge();
|
||||||
we_have(i);
|
we_have(i);
|
||||||
}
|
}
|
||||||
|
@ -2276,7 +2279,7 @@ namespace libtorrent
|
||||||
need_picker();
|
need_picker();
|
||||||
m_picker->we_have(piece);
|
m_picker->we_have(piece);
|
||||||
update_gauge();
|
update_gauge();
|
||||||
m_ses.inc_stats_counter(counters::num_piece_passed);
|
inc_stats_counter(counters::num_piece_passed);
|
||||||
we_have(piece);
|
we_have(piece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3317,7 +3320,7 @@ namespace libtorrent
|
||||||
torrent_state st = get_policy_state();
|
torrent_state st = get_policy_state();
|
||||||
torrent_peer* p = m_policy->connect_one_peer(m_ses.session_time(), &st);
|
torrent_peer* p = m_policy->connect_one_peer(m_ses.session_time(), &st);
|
||||||
peers_erased(st.erased);
|
peers_erased(st.erased);
|
||||||
m_ses.inc_stats_counter(counters::connection_attempt_loops, st.loop_counter);
|
inc_stats_counter(counters::connection_attempt_loops, st.loop_counter);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
|
@ -3865,7 +3868,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(m_ses.is_single_thread());
|
TORRENT_ASSERT(m_ses.is_single_thread());
|
||||||
TORRENT_ASSERT(!has_picker() || m_picker->has_piece_passed(index));
|
TORRENT_ASSERT(!has_picker() || m_picker->has_piece_passed(index));
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_have_pieces);
|
inc_stats_counter(counters::num_have_pieces);
|
||||||
|
|
||||||
// at this point, we have the piece for sure. It has been
|
// at this point, we have the piece for sure. It has been
|
||||||
// successfully written to disk. We may announce it to peers
|
// successfully written to disk. We may announce it to peers
|
||||||
|
@ -4041,7 +4044,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_need_save_resume_data = true;
|
m_need_save_resume_data = true;
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_piece_passed);
|
inc_stats_counter(counters::num_piece_passed);
|
||||||
|
|
||||||
remove_time_critical_piece(index, true);
|
remove_time_critical_piece(index, true);
|
||||||
|
|
||||||
|
@ -4129,7 +4132,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(index >= 0);
|
TORRENT_ASSERT(index >= 0);
|
||||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_piece_failed);
|
inc_stats_counter(counters::num_piece_failed);
|
||||||
|
|
||||||
if (m_ses.alerts().should_post<hash_failed_alert>())
|
if (m_ses.alerts().should_post<hash_failed_alert>())
|
||||||
m_ses.alerts().post_alert(hash_failed_alert(get_handle(), index));
|
m_ses.alerts().post_alert(hash_failed_alert(get_handle(), index));
|
||||||
|
@ -4242,7 +4245,7 @@ namespace libtorrent
|
||||||
// mark the peer as banned
|
// mark the peer as banned
|
||||||
ban_peer(p);
|
ban_peer(p);
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
m_ses.inc_stats_counter(counters::banned_for_hash_failure);
|
inc_stats_counter(counters::banned_for_hash_failure);
|
||||||
|
|
||||||
if (p->connection)
|
if (p->connection)
|
||||||
{
|
{
|
||||||
|
@ -4319,7 +4322,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (request_a_block(*this, c))
|
if (request_a_block(*this, c))
|
||||||
m_ses.inc_stats_counter(counters::interesting_piece_picks);
|
inc_stats_counter(counters::interesting_piece_picks);
|
||||||
c.send_block_requests();
|
c.send_block_requests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4638,7 +4641,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!m_apply_ip_filter)
|
if (!m_apply_ip_filter)
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::non_filter_torrents, -1);
|
inc_stats_counter(counters::non_filter_torrents, -1);
|
||||||
m_apply_ip_filter = true;
|
m_apply_ip_filter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6181,14 +6184,18 @@ namespace libtorrent
|
||||||
if (web->type == web_seed_entry::url_seed)
|
if (web->type == web_seed_entry::url_seed)
|
||||||
{
|
{
|
||||||
c = boost::make_shared<web_peer_connection>(
|
c = boost::make_shared<web_peer_connection>(
|
||||||
boost::ref(m_ses), m_ses.settings(), boost::ref(m_ses)
|
boost::ref(m_ses), m_ses.settings()
|
||||||
|
, boost::ref(m_ses.stats_counters())
|
||||||
|
, boost::ref(m_ses)
|
||||||
, boost::ref(m_ses.disk_thread())
|
, boost::ref(m_ses.disk_thread())
|
||||||
, shared_from_this(), s, boost::ref(*web));
|
, shared_from_this(), s, boost::ref(*web));
|
||||||
}
|
}
|
||||||
else if (web->type == web_seed_entry::http_seed)
|
else if (web->type == web_seed_entry::http_seed)
|
||||||
{
|
{
|
||||||
c = boost::make_shared<http_seed_connection>(
|
c = boost::make_shared<http_seed_connection>(
|
||||||
boost::ref(m_ses), m_ses.settings(), boost::ref(m_ses)
|
boost::ref(m_ses), m_ses.settings()
|
||||||
|
, boost::ref(m_ses.stats_counters())
|
||||||
|
, boost::ref(m_ses)
|
||||||
, boost::ref(m_ses.disk_thread())
|
, boost::ref(m_ses.disk_thread())
|
||||||
, shared_from_this(), s, boost::ref(*web));
|
, shared_from_this(), s, boost::ref(*web));
|
||||||
}
|
}
|
||||||
|
@ -7191,7 +7198,9 @@ namespace libtorrent
|
||||||
m_ses.setup_socket_buffers(*s);
|
m_ses.setup_socket_buffers(*s);
|
||||||
|
|
||||||
boost::shared_ptr<peer_connection> c = boost::make_shared<bt_peer_connection>(
|
boost::shared_ptr<peer_connection> c = boost::make_shared<bt_peer_connection>(
|
||||||
boost::ref(m_ses), m_ses.settings(), boost::ref(m_ses)
|
boost::ref(m_ses), m_ses.settings()
|
||||||
|
, boost::ref(m_ses.stats_counters())
|
||||||
|
, boost::ref(m_ses)
|
||||||
, boost::ref(m_ses.disk_thread())
|
, boost::ref(m_ses.disk_thread())
|
||||||
, s, a, peerinfo, m_ses.get_peer_id(), shared_from_this());
|
, s, a, peerinfo, m_ses.get_peer_id(), shared_from_this());
|
||||||
|
|
||||||
|
@ -7318,7 +7327,7 @@ namespace libtorrent
|
||||||
// we're a seed, because we have all 0 pieces
|
// we're a seed, because we have all 0 pieces
|
||||||
init();
|
init();
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_total_pieces_added
|
inc_stats_counter(counters::num_total_pieces_added
|
||||||
, m_torrent_file->num_pieces());
|
, m_torrent_file->num_pieces());
|
||||||
|
|
||||||
// disconnect redundant peers
|
// disconnect redundant peers
|
||||||
|
@ -8059,7 +8068,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (request_a_block(*this, *pc))
|
if (request_a_block(*this, *pc))
|
||||||
{
|
{
|
||||||
m_ses.inc_stats_counter(counters::unchoke_piece_picks);
|
inc_stats_counter(counters::unchoke_piece_picks);
|
||||||
pc->send_block_requests();
|
pc->send_block_requests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10416,7 +10425,7 @@ namespace libtorrent
|
||||||
need_policy();
|
need_policy();
|
||||||
torrent_peer* p = m_policy->connect_one_peer(m_ses.session_time(), &st);
|
torrent_peer* p = m_policy->connect_one_peer(m_ses.session_time(), &st);
|
||||||
peers_erased(st.erased);
|
peers_erased(st.erased);
|
||||||
m_ses.inc_stats_counter(counters::connection_attempt_loops, st.loop_counter);
|
inc_stats_counter(counters::connection_attempt_loops, st.loop_counter);
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
|
@ -10533,7 +10542,7 @@ namespace libtorrent
|
||||||
if (!m_policy->ban_peer(tp)) return false;
|
if (!m_policy->ban_peer(tp)) return false;
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
|
|
||||||
m_ses.inc_stats_counter(counters::num_banned_peers);
|
inc_stats_counter(counters::num_banned_peers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,8 +322,8 @@ namespace libtorrent { namespace
|
||||||
if (metadata_piece_size) m_pc.append_const_send_buffer(
|
if (metadata_piece_size) m_pc.append_const_send_buffer(
|
||||||
metadata, metadata_piece_size);
|
metadata, metadata_piece_size);
|
||||||
|
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_extended);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_metadata);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool on_extended(int length
|
virtual bool on_extended(int length
|
||||||
|
@ -425,7 +425,7 @@ namespace libtorrent { namespace
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pc.ses().inc_stats_counter(counters::num_incoming_metadata);
|
m_pc.stats_counters().inc_stats_counter(counters::num_incoming_metadata);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ namespace libtorrent { namespace
|
||||||
, num_dropped, num_added);
|
, num_dropped, num_added);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_pc.ses().inc_stats_counter(counters::num_incoming_pex);
|
m_pc.stats_counters().inc_stats_counter(counters::num_incoming_pex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,8 +496,8 @@ namespace libtorrent { namespace
|
||||||
m_pc.send_buffer(msg, sizeof(msg));
|
m_pc.send_buffer(msg, sizeof(msg));
|
||||||
m_pc.send_buffer(&pex_msg[0], pex_msg.size());
|
m_pc.send_buffer(&pex_msg[0], pex_msg.size());
|
||||||
|
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_extended);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_pex);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
lazy_entry m;
|
lazy_entry m;
|
||||||
|
@ -604,8 +604,8 @@ namespace libtorrent { namespace
|
||||||
m_pc.send_buffer(msg, sizeof(msg));
|
m_pc.send_buffer(msg, sizeof(msg));
|
||||||
m_pc.send_buffer(&pex_msg[0], pex_msg.size());
|
m_pc.send_buffer(&pex_msg[0], pex_msg.size());
|
||||||
|
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_extended);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
m_pc.ses().inc_stats_counter(counters::num_outgoing_pex);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
|
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
|
||||||
|
|
|
@ -54,13 +54,14 @@ namespace libtorrent
|
||||||
web_connection_base::web_connection_base(
|
web_connection_base::web_connection_base(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
, boost::shared_ptr<socket_type> s
|
, boost::shared_ptr<socket_type> s
|
||||||
, web_seed_entry& web)
|
, web_seed_entry& web)
|
||||||
: peer_connection(ses, sett, allocator, disk_thread, ses.get_io_service()
|
: peer_connection(ses, sett, stats_counters, allocator, disk_thread
|
||||||
, t, s, web.endpoint, &web.peer_info)
|
, ses.get_io_service(), t, s, web.endpoint, &web.peer_info)
|
||||||
, m_first_request(true)
|
, m_first_request(true)
|
||||||
, m_ssl(false)
|
, m_ssl(false)
|
||||||
, m_external_auth(web.auth)
|
, m_external_auth(web.auth)
|
||||||
|
|
|
@ -63,12 +63,14 @@ struct disk_interface;
|
||||||
web_peer_connection::web_peer_connection(
|
web_peer_connection::web_peer_connection(
|
||||||
aux::session_interface& ses
|
aux::session_interface& ses
|
||||||
, aux::session_settings const& sett
|
, aux::session_settings const& sett
|
||||||
|
, counters& stats_counters
|
||||||
, buffer_allocator_interface& allocator
|
, buffer_allocator_interface& allocator
|
||||||
, disk_interface& disk_thread
|
, disk_interface& disk_thread
|
||||||
, boost::weak_ptr<torrent> t
|
, boost::weak_ptr<torrent> t
|
||||||
, boost::shared_ptr<socket_type> s
|
, boost::shared_ptr<socket_type> s
|
||||||
, web_seed_entry& web)
|
, web_seed_entry& web)
|
||||||
: web_connection_base(ses, sett, allocator, disk_thread, t, s, web)
|
: web_connection_base(ses, sett, stats_counters, allocator, disk_thread
|
||||||
|
, t, s, web)
|
||||||
, m_url(web.url)
|
, m_url(web.url)
|
||||||
, m_web(&web)
|
, m_web(&web)
|
||||||
, m_received_body(0)
|
, m_received_body(0)
|
||||||
|
|
Loading…
Reference in New Issue